26 #include <core/exception.h>
27 #include <core/threading/mutex.h>
28 #include <core/threading/thread.h>
29 #include <core/threading/wait_condition.h>
37 typedef enum { WAITER, WAKER } threadmode_t;
39 class ExampleWaitCondThread :
public Thread
42 ExampleWaitCondThread(threadmode_t mode,
45 unsigned int sleep_time)
50 sleep_time_ = sleep_time;
56 if (mode_ == WAITER) {
58 cout << name() <<
": Waiting for waker" << endl;
61 cout << name() <<
": Woken up" << endl;
63 cout << name() <<
": EXCEPTION" << endl;
68 cout << name() <<
": Waking waiter" << endl;
69 waitcond_->wake_all();
70 cout << name() <<
": Woke waiter" << endl;
77 unsigned int sleep_time_;
81 main(
int argc,
char **argv)
85 ExampleWaitCondThread *t1 =
new ExampleWaitCondThread(WAITER,
"waiter1", w, 0);
86 ExampleWaitCondThread *t2 =
new ExampleWaitCondThread(WAITER,
"waiter2", w, 0);
87 ExampleWaitCondThread *tw =
new ExampleWaitCondThread(WAKER,
"waker", w, 2458642);
Base class for exceptions in Fawkes.
void print_trace()
Prints trace to stderr.
Thread class encapsulation of pthreads.
Wait until a given condition holds.
Fawkes library namespace.