4 Mutex::Mutex(char *title)
7 pthread_mutexattr_t attr;
8 pthread_mutexattr_init(&attr);
9 // pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
10 pthread_mutex_init(&mutex, &attr);
15 pthread_mutex_destroy(&mutex);
16 UNSET_ALL_LOCKS(this);
19 int Mutex::lock(char *location)
21 SET_LOCK(this, title, location);
22 if(pthread_mutex_lock(&mutex)) perror("Mutex::lock");
29 if(pthread_mutex_unlock(&mutex)) perror("Mutex::unlock");
35 return pthread_mutex_trylock(&mutex);
40 pthread_mutex_destroy(&mutex);
41 pthread_mutexattr_t attr;
42 pthread_mutexattr_init(&attr);
43 pthread_mutex_init(&mutex, &attr);