The wait() and wake() functions are not very complementary. I will be removing
wait() in favor of a simpler sleep() function, which is introduced here.
wait->set_state(THREAD_BLOCKED);
}
+/**
+ * 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 add_thread(Thread *t);
void remove_thread(Thread *t);
void wait(Thread *wait, Thread *join);
+ void sleep(Thread *t);
void wake(Thread *t);
Thread * next_thread(Thread *t);
Thread * get_current_thread() const;