15 #include "selectThreadImpl.h" 17 #ifdef HAVE_POSIX_THREADS 19 #include "conditionVarPosixImpl.h" 27 void ConditionVarPosixImpl::
28 wait(
double timeout) {
32 gettimeofday(&now, NULL);
36 ts.tv_sec = now.tv_sec;
37 ts.tv_nsec = now.tv_usec * 1000;
39 int seconds = (int)floor(timeout);
41 ts.tv_nsec += (int)((timeout - seconds) * 1000000.0);
42 if (ts.tv_nsec > 1000000) {
43 ts.tv_nsec -= 1000000;
47 int result = pthread_cond_timedwait(&_cvar, &_mutex._lock, &ts);
49 if (result != 0 && result != ETIMEDOUT) {
51 <<
"Unexpected error " << result <<
" from pthread_cond_timedwait()\n";
56 #endif // HAVE_POSIX_THREADS