diff thread/Thread.cpp @ 69:6afa0e011f74

* Fix some locking problems
author cannam
date Thu, 21 May 2009 16:39:35 +0000
parents b63f1ccbc9b6
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