X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.h;h=3f2cc974a455855c35246f7abc10d12d1993e709;hp=e6c09c54437e57ed3ae0cf8903a30c920c976760;hb=a1d6fa071280123f282c1bac3b68008672401024;hpb=6a38983c19fe78753962288e206c5817ad595448 diff --git a/source/core/semaphore.h b/source/core/semaphore.h index e6c09c5..3f2cc97 100644 --- a/source/core/semaphore.h +++ b/source/core/semaphore.h @@ -9,7 +9,6 @@ Distributed under the LGPL #define MSP_CORE_SEMAPHORE_H_ #include "mutex.h" -#include "types.h" #include "../time/timedelta.h" namespace Msp { @@ -17,39 +16,19 @@ namespace Msp { class Semaphore { private: - Mutex *mutex; - bool own_mutex; - SemaphoreHandle sem; -#ifdef WIN32 - unsigned count; -#endif + struct Private; + + Private *priv; public: - Semaphore(); - Semaphore(Mutex &); -private: - void init(); -public: + Semaphore(unsigned); ~Semaphore(); - int signal(); - int broadcast(); - int wait(); - int wait(const Time::TimeDelta &); - Mutex &get_mutex() { return *mutex; } + void signal(); + void wait(); + bool wait(const Time::TimeDelta &); }; -#ifndef WIN32 -inline int Semaphore::signal() -{ return pthread_cond_signal(&sem); } - -inline int Semaphore::broadcast() -{ return pthread_cond_broadcast(&sem); } - -inline int Semaphore::wait() -{ return pthread_cond_wait(&sem, &mutex->mutex); } -#endif - } #endif