]> 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 c55553a6f31d9ffd02b23040621ebb87337feff0..f5042892a1825bf1650f16e8ad93f833790f90a3 100644 (file)
@@ -1,50 +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 "mutex.h"
-#include "types.h"
-#include "../time/timedelta.h"
+#include <msp/time/timedelta.h>
+#include "mspcore_api.h"
+#include "noncopyable.h"
 
 namespace Msp {
 
-class Semaphore
+class MSPCORE_API Semaphore: private NonCopyable
 {
-public:
-       Semaphore();
-       Semaphore(Mutex &);
-       int   signal();
-       int   broadcast();
-       int   wait();
-       int   wait(const Time::TimeDelta &);
-       Mutex &get_mutex() { return *mutex; }
-       ~Semaphore();
 private:
-       Mutex *mutex;
-       bool  own_mutex;
-       SemaphoreHandle sem;
-#ifdef WIN32
-       unsigned count;
-#endif
-
-       void init();
-};
+       struct Private;
 
-#ifndef WIN32
-inline int Semaphore::signal()
-{ return pthread_cond_signal(&sem); }
+       Private *priv = nullptr;
 
-inline int Semaphore::broadcast()
-{ return pthread_cond_broadcast(&sem); }
+public:
+       Semaphore(unsigned);
+       ~Semaphore();
 
-inline int Semaphore::wait()
-{ return pthread_cond_wait(&sem, &mutex->mutex); }
-#endif
+       void signal();
+       void wait();
+       bool wait(const Time::TimeDelta &);
+};
 
 }