Bugfixes part 3 #209
@@ -135,17 +135,19 @@ bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout, std::funct
|
||||
if (condition()) break;
|
||||
bool isTimeout;
|
||||
#if defined(WINDOWS)
|
||||
isTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle,
|
||||
(PCRITICAL_SECTION)lk.handle(),
|
||||
timeout.toMilliseconds() - (int)measurer.elapsed_m()) == 0;
|
||||
{
|
||||
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
||||
if (remain <= 0) return false;
|
||||
isTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), remain) == 0;
|
||||
}
|
||||
#elif defined(FREERTOS)
|
||||
EventBits_t uxBits;
|
||||
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle,
|
||||
1,
|
||||
pdTRUE,
|
||||
pdTRUE,
|
||||
(timeout.toMilliseconds() - (int)measurer.elapsed_m()) / portTICK_PERIOD_MS);
|
||||
isTimeout = (uxBits & 1) == 0;
|
||||
{
|
||||
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
||||
if (remain <= 0) return false;
|
||||
EventBits_t uxBits;
|
||||
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, remain / portTICK_PERIOD_MS);
|
||||
isTimeout = (uxBits & 1) == 0;
|
||||
}
|
||||
#else
|
||||
isTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle(), &expire_ts) != 0;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user