Create WaitObj to store information about which thread is waiting for whom and is...
[c11tester.git] / waitobj.cc
1 #include "waitobj.h"
2
3 WaitObj::WaitObj(thread_id_t tid) :
4         tid(tid),
5         waiting_for(32),
6         waited_by(32),
7         dist_table(32)
8 {}
9
10 int WaitObj::lookup_dist(thread_id_t other_id)
11 {
12         if (dist_table.contains(other_id))
13                 return dist_table.get(other_id);
14
15         return -1;
16 }
17
18 void WaitObj::print_waiting_for()
19 {
20         if (waiting_for.getSize() == 0)
21                 return;
22
23         model_print("thread %d is waiting for: ", tid);
24         thrd_id_set_iter * it = waiting_for.iterator();
25
26         while (it->hasNext()) {
27                 thread_id_t thread_id = it->next();
28                 model_print("%d ", thread_id);
29         }
30         model_print("\n");
31 }
32
33 void WaitObj::print_waited_by()
34 {
35         if (waited_by.getSize() == 0)
36                 return;
37
38         model_print("thread %d is waited by: ", tid);
39         thrd_id_set_iter * it = waited_by.iterator();
40
41         while (it->hasNext()) {
42                 thread_id_t thread_id = it->next();
43                 model_print("%d ", thread_id);
44         }
45         model_print("\n");
46
47 }