2 This file is part of libmspframework
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
6 #ifndef MSP_FRAMEWORK_SEMAPHORE_H_
7 #define MSP_FRAMEWORK_SEMAPHORE_H_
11 #include "../time/timedelta.h"
19 Semaphore() { pthread_cond_init(&cond, 0); }
20 //Mutex &get_mutex() { return mutex; }
21 int signal() { MutexLock l(mutex); return pthread_cond_signal(&cond); }
22 int broadcast() { MutexLock l(mutex); return pthread_cond_broadcast(&cond); }
23 int wait() { mutex.lock(); return pthread_cond_wait(&cond, &mutex.mutex); }
24 int wait(const Time::TimeDelta &);
25 ~Semaphore() { pthread_cond_destroy(&cond); }