Documentation for concurrent and small improvements
git-svn-id: svn://db.shs.com.ru/pip@868 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
//
|
||||
|
||||
#include "piplatform.h"
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#include "synchapi.h"
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
#include "piconditionvar.h"
|
||||
@@ -68,15 +67,15 @@ void PIConditionVariable::wait(PIConditionLock& lk, const std::function<bool()>&
|
||||
}
|
||||
|
||||
bool PIConditionVariable::waitFor(PIConditionLock &lk, int timeoutMs) {
|
||||
bool isTimeout;
|
||||
bool isNotTimeout;
|
||||
#ifdef WINDOWS
|
||||
isTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), timeoutMs) != 0;
|
||||
isNotTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), timeoutMs) != 0;
|
||||
#else
|
||||
timespec abstime = {.tv_sec = timeoutMs / 1000, .tv_nsec = timeoutMs * 1000 * 1000};
|
||||
isTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t*)lk.handle(), &abstime) == 0;
|
||||
isNotTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t*)lk.handle(), &abstime) == 0;
|
||||
#endif
|
||||
if (PRIVATE->isDestroying) return false;
|
||||
return isTimeout;
|
||||
return isNotTimeout;
|
||||
}
|
||||
|
||||
bool PIConditionVariable::waitFor(PIConditionLock& lk, int timeoutMs, const std::function<bool()> &condition) {
|
||||
|
||||
Reference in New Issue
Block a user