Get GDAX working.
[c11tester.git] / include / mutex.h
1 /**
2  * @file mutex
3  * @brief C++11 mutex interface header
4  */
5
6 #ifndef __CXX_MUTEX__
7 #define __CXX_MUTEX__
8
9 #include "modeltypes.h"
10 #include "mymemory.h"
11
12 namespace cdsc {
13 struct mutex_state {
14         void *locked;   /* Thread holding the lock */
15         thread_id_t alloc_tid;
16         modelclock_t alloc_clock;
17         int init;       // WL
18 };
19
20 class mutex {
21 public:
22         mutex();
23         ~mutex() {}
24         void lock();
25         bool try_lock();
26         void unlock();
27         struct mutex_state * get_state() {return &state;}
28         void initialize() { state.init = 1; }   // WL
29         bool is_initialized() { return state.init == 1; }
30
31 private:
32         struct mutex_state state;
33 };
34
35 class snapmutex : public mutex {
36 public:
37         snapmutex() : mutex()
38         { }
39         SNAPSHOTALLOC
40 };
41 }
42 #endif  /* __CXX_MUTEX__ */