diff thread/Thread.cpp @ 294:2aed32965291

* Fix some locking problems
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 21 May 2009 16:39:35 +0000
parents f857c6e81833
children c10ac368f5cf
line wrap: on
line diff
--- a/thread/Thread.cpp	Mon May 18 15:44:03 2009 +0000
+++ b/thread/Thread.cpp	Thu May 21 16:39:35 2009 +0000
@@ -207,12 +207,6 @@
 void
 Condition::lock()
 {
-    if (m_locked) {
-#ifdef DEBUG_CONDITION
-        cerr << "CONDITION DEBUG: " << (void *)GetCurrentThreadId() << ": Already locked " << &m_condition << " \"" << m_name << "\"" << endl;
-#endif
-        return;
-    }
 #ifdef DEBUG_CONDITION
     cerr << "CONDITION DEBUG: " << (void *)GetCurrentThreadId() << ": Want to lock " << &m_condition << " \"" << m_name << "\"" << endl;
 #endif
@@ -468,12 +462,6 @@
 void
 Condition::lock()
 {
-    if (m_locked) {
-#ifdef DEBUG_CONDITION
-        cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Already locked " << &m_condition << " \"" << m_name << "\"" << endl;
-#endif
-        return;
-    }
 #ifdef DEBUG_CONDITION
     cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Want to lock " << &m_condition << " \"" << m_name << "\"" << endl;
 #endif
@@ -534,6 +522,8 @@
 #ifdef DEBUG_CONDITION
     cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Wait done on " << &m_condition << " \"" << m_name << "\"" << endl;
 #endif
+
+    m_locked = true;
 }
 
 void