X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.h;h=61118c734febffa1e5da463e5ead628074a144ad;hb=154d5f43f7a6633a4937499039fc1b1b713e0c0c;hp=e6c09c54437e57ed3ae0cf8903a30c920c976760;hpb=cfc8e0b7b15ea505bd6a6a9599cbc5ce1e316963;p=libs%2Fcore.git diff --git a/source/core/semaphore.h b/source/core/semaphore.h index e6c09c5..61118c7 100644 --- a/source/core/semaphore.h +++ b/source/core/semaphore.h @@ -1,55 +1,27 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_CORE_SEMAPHORE_H_ #define MSP_CORE_SEMAPHORE_H_ +#include #include "mutex.h" -#include "types.h" -#include "../time/timedelta.h" 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