00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef USE_NPTL
00024 #include <pthread.h>
00025 #else
00026 #include <nptl/pthread.h>
00027 #endif
00028
00029
00030 #ifndef MUTEX_HH
00031 #define MUTEX_HH
00032
00033
00037 class clMutex
00038 {
00039 pthread_mutex_t pthmMutex;
00040 public:
00044 clMutex () { pthread_mutex_init(&pthmMutex, NULL); }
00048 ~clMutex () { pthread_mutex_destroy(&pthmMutex); }
00055 bool Wait ()
00056 {
00057 if (pthread_mutex_lock(&pthmMutex) != 0)
00058 return false;
00059 return true;
00060 }
00066 bool Release ()
00067 {
00068 if (pthread_mutex_unlock(&pthmMutex) != 0)
00069 return false;
00070 return true;
00071 }
00077 bool TryLock ()
00078 {
00079 if (pthread_mutex_trylock(&pthmMutex) != 0)
00080 return false;
00081 return true;
00082 }
00089 pthread_mutex_t *GetPtr () { return (&pthmMutex); }
00090 };
00091
00092 #endif