platform: fixed return value from CCondition::Wait()
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 17 Feb 2012 01:58:48 +0000 (02:58 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 17 Feb 2012 10:39:30 +0000 (11:39 +0100)
src/lib/platform/threads/mutex.h

index 5a9ae135ee9858548c937b2faf395224fa44d7bb..6bd126e4c7452b1658e285386e5dd0f106917700 100644 (file)
@@ -257,18 +257,19 @@ namespace PLATFORM
         if (iTimeout == 0)
           return Wait(mutex, predicate);
 
-        bool bReturn(true);
-        if (!predicate)
+        if (predicate)
+          return true;
+
+        bool bReturn(false);
+        bool bBreak(false);
+        CTimeout timeout(iTimeout);
+        uint32_t iMsLeft(0);
+
+        while (!bReturn && !bBreak)
         {
-          CTimeout timeout(iTimeout);
-          uint32_t iMsLeft(0);
-          bReturn = false;
-          while (!bReturn)
-          {
-            iMsLeft = timeout.TimeLeft();
-            if ((bReturn = iMsLeft == 0 || predicate) == false)
-              m_condition.Wait(mutex.m_mutex, iMsLeft);
-          }
+          iMsLeft = timeout.TimeLeft();
+          if ((bReturn = predicate) == false && (bBreak = iMsLeft == 0) == false)
+            m_condition.Wait(mutex.m_mutex, iMsLeft);
         }
         return bReturn;
       }