From: Mikko Rasa Date: Tue, 3 Oct 2006 21:25:23 +0000 (+0000) Subject: Add a missing mutex unlock into Semaphore::wait X-Git-Tag: 1.0~31 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7292f4413397b7f2e4689f7597f4b9e73435352e;p=libs%2Fcore.git Add a missing mutex unlock into Semaphore::wait Make MutexLock noncopyable --- 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