deal with looping due to bogus future value via promise expiration
[model-checker.git] / schedule.cc
index d96172e010d445a2b06eff5b392b89161126f12e..cbb4957a3e4a3865730679e8e816dfb51f636324 100644 (file)
@@ -31,6 +31,27 @@ void Scheduler::remove_thread(Thread *t)
                readyList.remove(t);
 }
 
+/**
+ * Prevent a Thread from being scheduled. The sleeping Thread should be
+ * re-awoken via Scheduler::wake.
+ * @param thread The Thread that should sleep
+ */
+void Scheduler::sleep(Thread *t)
+{
+       remove_thread(t);
+       t->set_state(THREAD_BLOCKED);
+}
+
+/**
+ * Wake a Thread up that was previously waiting (see Scheduler::wait)
+ * @param t The Thread to wake up
+ */
+void Scheduler::wake(Thread *t)
+{
+       add_thread(t);
+       t->set_state(THREAD_READY);
+}
+
 /**
  * Remove one Thread from the scheduler. This implementation defaults to FIFO,
  * if a thread is not already provided.