27 #include <core/threading/mutex.h>
28 #include <core/threading/thread.h>
29 #include <core/threading/wait_condition.h>
45 class ExampleMutexWaitThread :
public Thread
48 ExampleMutexWaitThread(
string s) :
Thread(
"ExampleMutexWaitThread",
Thread::OPMODE_CONTINUOUS)
55 ~ExampleMutexWaitThread()
78 cout << s <<
": my turn" << endl;
88 class ExampleMutexWaitStarterThread :
public Thread
91 ExampleMutexWaitStarterThread()
92 :
Thread(
"ExampleMutexWaitStarterThread",
Thread::OPMODE_CONTINUOUS)
100 vector<ExampleMutexWaitThread *>::iterator tit;
101 for (tit = threads.begin(); tit != threads.end(); ++tit) {
102 cout <<
"Waking thread " << (*tit)->getS() << endl;
108 addThread(ExampleMutexWaitThread *t)
110 threads.push_back(t);
121 vector<ExampleMutexWaitThread *> threads;
128 main(
int argc,
char **argv)
130 ExampleMutexWaitThread *t1 =
new ExampleMutexWaitThread(
"t1");
131 ExampleMutexWaitThread *t2 =
new ExampleMutexWaitThread(
"t2");
132 ExampleMutexWaitThread *t3 =
new ExampleMutexWaitThread(
"t3");
134 ExampleMutexWaitStarterThread *st =
new ExampleMutexWaitStarterThread();
Mutex mutual exclusion lock.
Thread class encapsulation of pthreads.
Fawkes library namespace.