Mutex.h

Go to the documentation of this file.
00001 /*
00002  * $Id: Mutex.h 562 2007-12-02 08:04:16Z mindstorm2600 $
00003  *
00004  * X-VR2 
00005  * 
00006  * Copyright (C) Juan V. Guerrero 2007
00007  * 
00008  * Juan V. Guerrero <mindstorm2600@users.sourceforge.net>
00009  * 
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License Version 2. See the LICENSE file
00012  * at the top of the source tree.
00013  */
00014 #ifndef __XVR2_MUTEX_H__
00015 #define __XVR2_MUTEX_H__
00016 
00017 #ifdef USE_GNUPTH
00018 #include<pth.h>
00019 #else
00020 #ifdef USE_SDL
00021 #include<xvr2/SDL.h>
00022 #else
00023 #include<pthread.h>
00024 #endif
00025 #endif
00026 
00027 #include<xvr2/Threading.h>
00028 #include<xvr2/CoreExceptions.h>
00029 namespace xvr2{
00030 
00035         class Mutex:public Object{
00036          private:
00039           void destroy();
00040          public:
00042 #ifdef USE_GNUPTH
00043           pth_mutex_t mutex;
00044 #else
00045 #ifdef USE_SDL
00046             SDL_mutex *mutex;
00047 #else
00048             pthread_mutex_t mutex;
00049             pthread_mutexattr_t m_attr;
00050 #endif
00051         #endif
00052 
00055           Mutex(int autoinit = 1);
00058           virtual ~Mutex();     
00061           void init();
00063           void lock();
00066           void trylock();
00068           void unlock();
00069         };
00070 
00071         class MutexAlreadyLocked : public MutexException {
00072                 public:
00073                         MutexAlreadyLocked();
00074         };
00075 }
00076 
00077 #endif

Generated on Fri Jun 20 22:55:47 2008 for X-VR2 SDK by  doxygen 1.5.5