5 #include <xbt/synchro.h>
9 mutex_t() { mutex = xbt_mutex_init(); }
10 ~mutex_t() { xbt_mutex_destroy(mutex); }
11 void acquire() { xbt_mutex_acquire(mutex); }
12 void release() { xbt_mutex_release(mutex); }
17 friend class condition_t;
22 condition_t() { cond = xbt_cond_init(); }
23 ~condition_t() { xbt_cond_destroy(cond); }
24 void broadcast() { xbt_cond_broadcast(cond); }
25 void signal() { xbt_cond_signal(cond); }
26 void wait(mutex_t& mutex) { xbt_cond_wait(cond, mutex.mutex); }
27 bool timedwait(mutex_t& mutex, double delay) {
29 xbt_cond_timedwait(cond, mutex.mutex, delay);
31 catch (const xbt_ex& e) {
32 if (e.category != timeout_error)
35 return false; // got a timeout