00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _POSIXLOCK_H_
00028 #define _POSIXLOCK_H_
00029
00030 #if !defined(_WIN32)
00031
00032 #include <pthread.h>
00033
00039 namespace HL {
00040
00041 class PosixLockType {
00042 public:
00043
00044 PosixLockType (void)
00045 {
00046 int r = pthread_mutex_init (&mutex, NULL);
00047 if (r) {
00048 throw 0;
00049 }
00050 }
00051
00052 ~PosixLockType (void)
00053 {
00054 pthread_mutex_destroy (&mutex);
00055 }
00056
00057 void lock (void) {
00058 pthread_mutex_lock (&mutex);
00059 }
00060
00061 void unlock (void) {
00062 pthread_mutex_unlock (&mutex);
00063 }
00064
00065 private:
00066 union {
00067 pthread_mutex_t mutex;
00068 double _dummy[sizeof(pthread_mutex_t)/sizeof(double) + 1];
00069 };
00070 };
00071
00072 }
00073
00074 #endif
00075
00076 #endif