]> AND Private Git Repository - loba.git/blobdiff - synchro.h
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Save notes for pstar.
[loba.git] / synchro.h
index a2e86f3c1cb9d273d1f1d3a135a87e609b86311d..bd49783ccdc943f2710ed76f9e4e60787fb0b5cf 100644 (file)
--- a/synchro.h
+++ b/synchro.h
@@ -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 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:
     }
 
 private: