27 #include <core/threading/thread.h> 28 #include <core/threading/wait_condition.h> 29 #include <core/threading/mutex.h> 45 class ExampleMutexWaitThread :
public Thread 48 ExampleMutexWaitThread(
string s)
49 :
Thread(
"ExampleMutexWaitThread",
Thread::OPMODE_CONTINUOUS)
56 ~ExampleMutexWaitThread()
75 cout << s <<
": my turn" << endl;
86 class ExampleMutexWaitStarterThread :
public Thread 89 ExampleMutexWaitStarterThread()
90 :
Thread(
"ExampleMutexWaitStarterThread",
Thread::OPMODE_CONTINUOUS)
97 vector< ExampleMutexWaitThread * >::iterator tit;
98 for (tit = threads.begin(); tit != threads.end(); ++tit) {
99 cout <<
"Waking thread " << (*tit)->getS() << endl;
104 void addThread(ExampleMutexWaitThread *t)
106 threads.push_back(t);
117 vector< ExampleMutexWaitThread * > threads;
124 main(
int argc,
char **argv)
127 ExampleMutexWaitThread *t1 =
new ExampleMutexWaitThread(
"t1");
128 ExampleMutexWaitThread *t2 =
new ExampleMutexWaitThread(
"t2");
129 ExampleMutexWaitThread *t3 =
new ExampleMutexWaitThread(
"t3");
131 ExampleMutexWaitStarterThread *st =
new ExampleMutexWaitStarterThread();
Fawkes library namespace.
Thread class encapsulation of pthreads.
Mutex mutual exclusion lock.