forgot to add two files...
[model-checker.git] / conditionvariable.cc
diff --git a/conditionvariable.cc b/conditionvariable.cc
new file mode 100644 (file)
index 0000000..5bd0beb
--- /dev/null
@@ -0,0 +1,26 @@
+#include <mutex>
+#include "model.h"
+#include "conditionvariable.h"
+
+
+namespace std {
+
+condition_variable::condition_variable() {
+               
+}
+
+void condition_variable::notify_one() {
+       model->switch_to_master(new ModelAction(ATOMIC_NOTIFY_ONE, std::memory_order_seq_cst, this));
+}
+
+void condition_variable::notify_all() {
+       model->switch_to_master(new ModelAction(ATOMIC_NOTIFY_ALL, std::memory_order_seq_cst, this));
+}
+
+void condition_variable::wait(mutex& lock) {
+       model->switch_to_master(new ModelAction(ATOMIC_WAIT, std::memory_order_seq_cst, this, (uint64_t) &lock));
+       //relock as a second action
+       lock.lock();
+}
+}
+