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