win32: fix < vista compilation
[deb_libcec.git] / src / lib / platform / windows / os-threads.h
index 0e738684a1f599dca64e567ed60c731acb87ee0b..df1af39e5f0c82e6daa918eb8b99fefafd515853 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -57,9 +57,13 @@ namespace PLATFORM
   #define ConditionDelete(cond)                    ::CloseHandle(cond)
   #define ConditionSignal(cond)                    ::SetEvent(cond)
   #define ConditionBroadcast(cond)                 ::SetEvent(cond)
-  #define ConditionWait(cond, mutex, timeout)      ::ResetEvent(cond); \
-                                                   MutexUnlock(mutex); \
-                                                   ::WaitForSingleObject(cond, timeout <= 0 ? 1000 : timeout); \
-                                                   MutexLock(mutex)
+  inline bool ConditionWait(condition_t cond, mutex_t mutex, uint32_t iTimeoutMsg)
+  {
+    ::ResetEvent(cond);
+    MutexUnlock(mutex);
+    DWORD iWaitReturn = ::WaitForSingleObject(cond, iTimeoutMsg <= 0 ? 1000 : iTimeoutMsg);
+    MutexLock(mutex);
+    return iWaitReturn == 0;
+  }
   #endif
 }