24 #include <core/threading/mutex.h>
25 #include <core/threading/thread.h>
36 for (unsigned int i = 0; i < 1000000; i++) { \
45 class ExampleMutexCountThread :
public Thread
55 ExampleMutexCountThread(
string s,
57 unsigned int *mutex_count,
58 unsigned int *non_mutex_count,
59 unsigned int sleep_time)
60 :
Thread(
"ExampMutexCountThread",
Thread::OPMODE_CONTINUOUS)
64 this->slt = sleep_time;
66 this->mc = mutex_count;
67 this->nmc = non_mutex_count;
77 unsigned int n = *nmc;
96 cout << s <<
": mutex: " << *mc <<
"(non-mutex: " << *nmc <<
")" << endl;
114 main(
int argc,
char **argv)
118 unsigned int mutex_count = 0;
119 unsigned int non_mutex_count = 0;
121 ExampleMutexCountThread *t1 =
122 new ExampleMutexCountThread(
"t1", m, &mutex_count, &non_mutex_count, 1000);
123 ExampleMutexCountThread *t2 =
124 new ExampleMutexCountThread(
"t2", m, &mutex_count, &non_mutex_count, 10000);
125 ExampleMutexCountThread *t3 =
126 new ExampleMutexCountThread(
"t3", m, &mutex_count, &non_mutex_count, 100000);