Add some methods for WaitObj
[c11tester.git] / waitobj.h
1 #ifndef __WAITOBJ_H__
2 #define __WAITOBJ_H__
3
4 #include "classlist.h"
5 #include "modeltypes.h"
6
7 class WaitObj {
8 public:
9         WaitObj(thread_id_t);
10         ~WaitObj() {}
11
12         thread_id_t get_tid() { return tid; }
13
14         void add_waiting_for(thread_id_t other, int dist);
15         void add_waited_by(thread_id_t other);
16         void remove_waiting_for(thread_id_t other);
17         void remove_waited_by(thread_id_t other);
18
19         thrd_id_set_t * getWaitingFor() { return &waiting_for; }
20         thrd_id_set_t * getWaitingBy() { return &waited_by; }
21         int lookup_dist(thread_id_t other_tid);
22
23         void reset();
24
25         void print_waiting_for();
26         void print_waited_by();
27
28         SNAPSHOTALLOC
29 private:
30         thread_id_t tid;
31
32         /* The set of threads this thread (tid) is waiting for */
33         thrd_id_set_t waiting_for;
34
35         /* The set of threads waiting for this thread */
36         thrd_id_set_t waited_by;
37
38         HashTable<thread_id_t, int, int, 0> dist_table;
39 };
40
41 #endif