X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/5c7ecee696b69e6177921d0077a2b1875f6e3f00..f581799445893c1b953c365fbfb025e3dbcc775a:/synchro.h?ds=sidebyside diff --git a/synchro.h b/synchro.h index e366bee..fed9e87 100644 --- a/synchro.h +++ b/synchro.h @@ -23,8 +23,19 @@ 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); + mutex.acquire(); + return false; // got a timeout + } + return true; } private: