Update readme
[c11tester.git] / include / mutex.h
index e015ea599f7373d59125f3eaf69fcfce7e1f3a0e..1f573bd1e51dd128e0b5b8982aa113f5f70a212c 100644 (file)
@@ -7,29 +7,36 @@
 #define __CXX_MUTEX__
 
 #include "modeltypes.h"
-//#include <mutex>
+#include "mymemory.h"
+#include "mypthread.h"
 
 namespace cdsc {
-       struct mutex_state {
-               void *locked; /* Thread holding the lock */
-               thread_id_t alloc_tid;
-               modelclock_t alloc_clock;
-               int init; // WL
-       };
+struct mutex_state {
+       void *locked;   /* Thread holding the lock */
+       thread_id_t alloc_tid;
+       modelclock_t alloc_clock;
+       int type;
+       int lock_count;
+};
 
-       class mutex {
-       public:
-               mutex();
-               ~mutex() {}
-               void lock();
-               bool try_lock();
-               void unlock();
-               struct mutex_state * get_state() {return &state;}
-               void initialize() { state.init = 1; } // WL
-               bool is_initialized() { return state.init == 1; }
-               
-       private:
-               struct mutex_state state;
-       };
+class mutex {
+public:
+       mutex(int type = PTHREAD_MUTEX_DEFAULT);
+       ~mutex() {}
+       void lock();
+       bool try_lock();
+       void unlock();
+       struct mutex_state * get_state() {return &state;}
+
+private:
+       struct mutex_state state;
+};
+
+class snapmutex : public mutex {
+public:
+       snapmutex(int type = 0) : mutex(type)
+       { }
+       SNAPSHOTALLOC
+};
 }
-#endif /* __CXX_MUTEX__ */
+#endif /* __CXX_MUTEX__ */