00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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