]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/semaphore.h
Add move semantics to Variant
[libs/core.git] / source / core / semaphore.h
index 75c51e6a424716deee151e3bedfd7eb80342e006..f5042892a1825bf1650f16e8ad93f833790f90a3 100644 (file)
@@ -1,32 +1,26 @@
-/*
-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 <pthread.h>
-#include "mutex.h"
-#include "../time/timedelta.h"
+#ifndef MSP_CORE_SEMAPHORE_H_
+#define MSP_CORE_SEMAPHORE_H_
+
+#include <msp/time/timedelta.h>
+#include "mspcore_api.h"
+#include "noncopyable.h"
 
 namespace Msp {
 
-class Semaphore
+class MSPCORE_API Semaphore: private NonCopyable
 {
-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 = nullptr;
+
+public:
+       Semaphore(unsigned);
+       ~Semaphore();
+
+       void signal();
+       void wait();
+       bool wait(const Time::TimeDelta &);
 };
 
 }