X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.h;h=627c91894a27db34f2ee23e78f1ed23a2321d6c0;hb=d3fc0bf0f20f100f2831188c1ce21461d21c2c7a;hp=75c51e6a424716deee151e3bedfd7eb80342e006;hpb=e1ea831a640fba534e7e42e399f04cdf681ef8d3;p=libs%2Fcore.git diff --git a/source/core/semaphore.h b/source/core/semaphore.h index 75c51e6..627c918 100644 --- a/source/core/semaphore.h +++ b/source/core/semaphore.h @@ -1,12 +1,6 @@ -/* -This file is part of libmspframework -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ -#ifndef MSP_FRAMEWORK_SEMAPHORE_H_ -#define MSP_FRAMEWORK_SEMAPHORE_H_ - -#include +#ifndef MSP_CORE_SEMAPHORE_H_ +#define MSP_CORE_SEMAPHORE_H_ + #include "mutex.h" #include "../time/timedelta.h" @@ -14,19 +8,18 @@ namespace Msp { class Semaphore { -public: -#ifndef WIN32 - Semaphore() { pthread_cond_init(&cond, 0); } - //Mutex &get_mutex() { return mutex; } - int signal() { MutexLock l(mutex); return pthread_cond_signal(&cond); } - int broadcast() { MutexLock l(mutex); return pthread_cond_broadcast(&cond); } - int wait() { mutex.lock(); return pthread_cond_wait(&cond, &mutex.mutex); } - int wait(const Time::TimeDelta &); - ~Semaphore() { pthread_cond_destroy(&cond); } -#endif private: - Mutex mutex; - pthread_cond_t cond; + struct Private; + + Private *priv; + +public: + Semaphore(unsigned); + ~Semaphore(); + + void signal(); + void wait(); + bool wait(const Time::TimeDelta &); }; }