]> git.tdb.fi Git - libs/core.git/commitdiff
Add a missing mutex unlock into Semaphore::wait
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Oct 2006 21:25:23 +0000 (21:25 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Oct 2006 21:25:23 +0000 (21:25 +0000)
Make MutexLock noncopyable

source/core/mutex.h
source/core/semaphore.h

index b619fcdb7c6b9127a550a296c9f4cb521d0d3ecc..99585103704d00d4bbde53edf3927975286f0898 100644 (file)
@@ -40,6 +40,9 @@ public:
        ~MutexLock()                  { mutex.unlock(); }
 private:
        Mutex &mutex;
+
+       MutexLock(const MutexLock &);
+       MutexLock &operator=(const MutexLock &);
 };
 
 
index a7cdff7371d4f301468ff42da669cea6daa5db26..b060947b57e0d0aaf661b9a04c1141f4c3f3d3dc 100644 (file)
@@ -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