Coin Logo http://www.sim.no/
http://www.coin3d.org/

SbMutex.h
00001 #ifndef COIN_SBMUTEX_H
00002 #define COIN_SBMUTEX_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) by Kongsberg Oil & Gas Technologies.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/SbBasic.h>
00028 #include <Inventor/C/threads/mutex.h>
00029 
00030 class SbMutex {
00031 public:
00032   SbMutex(void) { this->mutex = cc_mutex_construct(); }
00033   ~SbMutex() { cc_mutex_destruct(this->mutex); }
00034 
00035   int lock(void) {
00036     cc_mutex_lock(this->mutex);
00037     /* Useless return, here just for compatibility with TGS'
00038        SbThreadMutex API: */
00039     return 0;
00040   }
00041 
00042   SbBool tryLock(void) {
00043     return cc_mutex_try_lock(this->mutex) == CC_OK;
00044   }
00045 
00046   int unlock(void) {
00047     cc_mutex_unlock(this->mutex);
00048     /* Useless return, here just for compatibility with TGS'
00049        SbThreadMutex API: */
00050     return 0;
00051   }
00052 
00053 private:
00054   // FIXME: we need access to C mutex structur. Should we use friend,
00055   // or should we add a new public method to get to this structure?
00056   // pederb, 2002-06-26
00057   friend class SbCondVar;
00058   cc_mutex * mutex;
00059 };
00060 
00061 
00062 #ifndef COIN_INTERNAL
00063 // For TGS Inventor compile-time compatibility.
00064 #include <Inventor/threads/SbThreadAutoLock.h>
00065 #endif // COIN_INTERNAL
00066 
00067 #endif // !COIN_SBMUTEX_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Thu Apr 28 2011 03:43:03 for Coin by Doxygen 1.7.4.