From 7292f4413397b7f2e4689f7597f4b9e73435352e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 3 Oct 2006 21:25:23 +0000 Subject: [PATCH] Add a missing mutex unlock into Semaphore::wait Make MutexLock noncopyable --- source/core/mutex.h | 3 +++ source/core/semaphore.h | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/core/mutex.h b/source/core/mutex.h index b619fcd..9958510 100644 --- a/source/core/mutex.h +++ b/source/core/mutex.h @@ -40,6 +40,9 @@ public: ~MutexLock() { mutex.unlock(); } private: Mutex &mutex; + + MutexLock(const MutexLock &); + MutexLock &operator=(const MutexLock &); }; diff --git a/source/core/semaphore.h b/source/core/semaphore.h index a7cdff7..b060947 100644 --- a/source/core/semaphore.h +++ b/source/core/semaphore.h @@ -17,10 +17,9 @@ class Semaphore public: #ifndef WIN32 Semaphore() { pthread_cond_init(&sem, 0); } - //Mutex &get_mutex() { return mutex; } int signal() { MutexLock l(mutex); return pthread_cond_signal(&sem); } int broadcast() { MutexLock l(mutex); return pthread_cond_broadcast(&sem); } - int wait() { mutex.lock(); return pthread_cond_wait(&sem, &mutex.mutex); } + int wait() { MutexLock l(mutex); return pthread_cond_wait(&sem, &mutex.mutex); } int wait(const Time::TimeDelta &); ~Semaphore() { pthread_cond_destroy(&sem); } #else -- 2.45.2