-
-void xbt_os_cond_timedwait(xbt_os_cond_t cond, xbt_os_mutex_t mutex, double delay)
-{
- int errcode;
- struct timespec ts_end;
- double end = delay + xbt_os_time();
-
- if (delay < 0) {
- xbt_os_cond_wait(cond, mutex);
- } else {
- ts_end.tv_sec = (time_t) floor(end);
- ts_end.tv_nsec = (long) ((end - ts_end.tv_sec) * 1000000000);
- XBT_DEBUG("pthread_cond_timedwait(%p,%p,%p)", &(cond->c), &(mutex->m), &ts_end);
- switch ((errcode = pthread_cond_timedwait(&(cond->c), &(mutex->m), &ts_end))) {
- case 0:
- return;
- case ETIMEDOUT:
- THROWF(timeout_error, errcode,
- "condition %p (mutex %p) wasn't signaled before timeout (%f)",
- cond, mutex, delay);
- default:
- THROWF(system_error, errcode, "pthread_cond_timedwait(%p,%p,%f) failed: %s", cond, mutex, delay, strerror(errcode));
- }
- }
-}
-