- void timedwait(mutex_t& mutex, double delay) {
- xbt_cond_timedwait(cond, mutex.mutex, delay);
+ bool timedwait(mutex_t& mutex, double delay) {
+ try {
+ xbt_cond_timedwait(cond, mutex.mutex, delay);
+ }
+ catch (const xbt_ex& e) {
+ if (e.category != timeout_error)
+ throw;
+ mutex.acquire();
+ return false; // got a timeout
+ }
+ return true;