X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/5c7ecee696b69e6177921d0077a2b1875f6e3f00..4d5ec9803b74d0f3e9c002a92a748bd08b6640ac:/synchro.h diff --git a/synchro.h b/synchro.h index e366bee..bd49783 100644 --- a/synchro.h +++ b/synchro.h @@ -1,7 +1,7 @@ #ifndef SYNCHRO_H #define SYNCHRO_H -#include +#include class mutex_t { public: @@ -23,8 +23,12 @@ 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) { + if (xbt_cond_timedwait(cond, mutex.mutex, delay)) { + mutex.acquire(); + return false; // got a timeout + } + return true; } private: