2cf6828af0ac679811d0fe7cac42d57502fe60d9
[c11tester.git] / mutex.cc
1 #include "mutex.h"
2 #include "model.h"
3
4
5 namespace std {
6 mutex::mutex() {
7         state.islocked=false;
8 }
9         
10 void mutex::lock() {
11   model->switch_to_master(new ModelAction(ATOMIC_LOCK, std::memory_order_seq_cst, this));
12 }
13         
14 bool mutex::try_lock() {
15   model->switch_to_master(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this));
16   return thread_current()->get_return_value();
17 }
18
19 void mutex::unlock() {
20   model->switch_to_master(new ModelAction(ATOMIC_UNLOCK, std::memory_order_seq_cst, this));
21 }
22
23 }