4 #include <xbt/synchro_core.h>
8 mutex_t() { mutex = xbt_mutex_init(); }
9 ~mutex_t() { xbt_mutex_destroy(mutex); }
10 void acquire() { xbt_mutex_acquire(mutex); }
11 void release() { xbt_mutex_release(mutex); }
16 friend class condition_t;
21 condition_t() { cond = xbt_cond_init(); }
22 ~condition_t() { xbt_cond_destroy(cond); }
23 void broadcast() { xbt_cond_broadcast(cond); }
24 void signal() { xbt_cond_signal(cond); }
25 void wait(mutex_t& mutex) { xbt_cond_wait(cond, mutex.mutex); }
26 bool timedwait(mutex_t& mutex, double delay) {
29 xbt_cond_timedwait(cond, mutex.mutex, delay);
32 if (e.category != timeout_error)
36 return false; // got a timeout