LibCecSharp: fixed - set the primary LA in CecLogicalAddresses
[deb_libcec.git] / src / lib / platform / threads / mutex.h
index 5a9ae135ee9858548c937b2faf395224fa44d7bb..00953db0e0cdada4aee48de1cdf4f191a04806bb 100644 (file)
  *     http://www.pulse-eight.net/
  */
 
-#include "../os.h"
+#include "lib/platform/os.h"
 
 #if defined(__WINDOWS__)
-#include "../windows/os-threads.h"
+#include "lib/platform/windows/os-threads.h"
 #else
-#include "../posix/os-threads.h"
+#include "lib/platform/posix/os-threads.h"
 #endif
 
-#include "../util/timeutils.h"
+#include "lib/platform/util/timeutils.h"
 
 namespace PLATFORM
 {
@@ -51,7 +51,7 @@ namespace PLATFORM
 
   private:
     inline PreventCopy(const PreventCopy &c) { *this = c; }
-    inline PreventCopy &operator=(const PreventCopy &c){ *this = c; return *this; }
+    inline PreventCopy &operator=(const PreventCopy & UNUSED(c)){ return *this; }
   };
 
   template <typename _Predicate>
@@ -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;
       }
@@ -342,11 +343,11 @@ namespace PLATFORM
       return bReturn;
     }
 
-    volatile bool              m_bSignaled;
-    CCondition<volatile bool&> m_condition;
-    CMutex                     m_mutex;
-    volatile bool              m_bBroadcast;
-    unsigned int               m_iWaitingThreads;
-    bool                       m_bAutoReset;
+    volatile bool             m_bSignaled;
+    CCondition<volatile bool> m_condition;
+    CMutex                    m_mutex;
+    volatile bool             m_bBroadcast;
+    unsigned int              m_iWaitingThreads;
+    bool                      m_bAutoReset;
   };
 }