X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/4878eece18057b563452421a54979f7f11bad8fb..3634a92de5281a6b19ca03b49b21dad853f386b3:/synchro.h?ds=sidebyside diff --git a/synchro.h b/synchro.h index e366bee..45e0901 100644 --- a/synchro.h +++ b/synchro.h @@ -23,8 +23,18 @@ public: void broadcast() { xbt_cond_broadcast(cond); } void signal() { xbt_cond_signal(cond); } void wait(mutex_t& mutex) { xbt_cond_wait(cond, mutex.mutex); } - void timedwait(mutex_t& mutex, double delay) { - xbt_cond_timedwait(cond, mutex.mutex, delay); + bool timedwait(mutex_t& mutex, double delay) { + xbt_ex_t e; + TRY { + xbt_cond_timedwait(cond, mutex.mutex, delay); + } + CATCH (e) { + if (e.category != timeout_error) + RETHROW; + xbt_ex_free(e); + return false; // got a timeout + } + return true; } private: