16 #ifdef HAVE_POSIX_THREADS 24 void ConditionVarPosixImpl::
25 wait(
double timeout) {
29 gettimeofday(&now,
nullptr);
33 ts.tv_sec = now.tv_sec;
34 ts.tv_nsec = now.tv_usec * 1000;
36 int seconds = (int)floor(timeout);
38 ts.tv_nsec += (int)((timeout - seconds) * 1000000.0);
39 if (ts.tv_nsec > 1000000) {
40 ts.tv_nsec -= 1000000;
44 int result = pthread_cond_timedwait(&_cvar, &_mutex._lock, &ts);
46 if (result != 0 && result != ETIMEDOUT) {
48 <<
"Unexpected error " << result <<
" from pthread_cond_timedwait()\n";
53 #endif // HAVE_POSIX_THREADS PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.