Merge branch 'master' of ssh://demsky.eecs.uci.edu/home/git/model-checker
[model-checker.git] / conditionvariable.cc
1 #include <mutex>
2 #include "model.h"
3 #include <condition_variable>
4 #include "action.h"
5
6 namespace std {
7
8 condition_variable::condition_variable() {
9                 
10 }
11
12 condition_variable::~condition_variable() {
13                 
14 }
15
16 void condition_variable::notify_one() {
17         model->switch_to_master(new ModelAction(ATOMIC_NOTIFY_ONE, std::memory_order_seq_cst, this));
18 }
19
20 void condition_variable::notify_all() {
21         model->switch_to_master(new ModelAction(ATOMIC_NOTIFY_ALL, std::memory_order_seq_cst, this));
22 }
23
24 void condition_variable::wait(mutex& lock) {
25         model->switch_to_master(new ModelAction(ATOMIC_WAIT, std::memory_order_seq_cst, this, (uint64_t) &lock));
26         //relock as a second action
27         lock.lock();
28 }
29 }
30