add support for pthread_mutex
[c11tester.git] / include / mutex
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
11 namespace std {
12         struct mutex_state {
13                 void *locked; /* Thread holding the lock */
14                 thread_id_t alloc_tid;
15                 modelclock_t alloc_clock;
16                 int init; // WL
17         };
18
19         class mutex {
20         public:
21                 mutex();
22                 ~mutex() {}
23                 void lock();
24                 bool try_lock();
25                 void unlock();
26                 struct mutex_state * get_state() {return &state;}
27                 void initialize() { state.init = 1; } // WL
28                 bool is_initialized() { return state.init == 1; }
29                 
30         private:
31                 struct mutex_state state;
32         };
33 }
34 #endif /* __CXX_MUTEX__ */