support for locks... untested, but doesn't break quick run of a sample of test cases
[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 }