From: Lars Op den Kamp Date: Tue, 14 Feb 2012 10:39:56 +0000 (+0100) Subject: platform: added CCondition::Wait() without a timeout for windows. fixes compilation... X-Git-Tag: upstream/2.2.0~1^2~35^2~60 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fd09ec0240599e6db5ae60bff0ee2d9da044c08d;p=deb_libcec.git platform: added CCondition::Wait() without a timeout for windows. fixes compilation on windows --- diff --git a/src/lib/platform/windows/os-threads.h b/src/lib/platform/windows/os-threads.h index 52bd4bc..e082691 100644 --- a/src/lib/platform/windows/os-threads.h +++ b/src/lib/platform/windows/os-threads.h @@ -116,17 +116,36 @@ namespace PLATFORM ::SetEvent(m_conditionPreVista); } + bool Wait(mutex_t &mutex) + { + if (m_bOnVista) + { + return ((*g_SleepConditionVariableCS)(m_conditionVista, mutex, INFINITE) ? true : false); + } + else + { + ::ResetEvent(m_conditionPreVista); + MutexUnlock(mutex); + DWORD iWaitReturn = ::WaitForSingleObject(m_conditionPreVista, 1000); + MutexLock(mutex); + return (iWaitReturn == 0); + } + } + bool Wait(mutex_t &mutex, uint32_t iTimeoutMs) { + if (iTimeoutMs == 0) + return Wait(mutex); + if (m_bOnVista) { - return ((*g_SleepConditionVariableCS)(m_conditionVista, mutex, iTimeoutMs <= 0 ? INFINITE : iTimeoutMs) ? true : false); + return ((*g_SleepConditionVariableCS)(m_conditionVista, mutex, iTimeoutMs) ? true : false); } else { ::ResetEvent(m_conditionPreVista); MutexUnlock(mutex); - DWORD iWaitReturn = ::WaitForSingleObject(m_conditionPreVista, iTimeoutMs <= 0 ? 1000 : iTimeoutMs); + DWORD iWaitReturn = ::WaitForSingleObject(m_conditionPreVista, iTimeoutMs); MutexLock(mutex); return (iWaitReturn == 0); }