threads: add THREAD_BLOCKED state
authorBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:41:12 +0000 (13:41 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:48:11 +0000 (13:48 -0700)
To signal that a Thread cannot yet be added back to the Scheduler's ready list.

threads.h

index 25b1d64..9396760 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -28,6 +28,11 @@ typedef enum thread_state {
         * context.
         */
        THREAD_READY,
+       /**
+        * Thread is waiting on another action (e.g., thread completion, lock
+        * release, etc.)
+        */
+       THREAD_BLOCKED,
        /** Thread has completed its execution */
        THREAD_COMPLETED
 } thread_state;
@@ -71,6 +76,9 @@ public:
        /** @return True if this thread is finished executing */
        bool is_complete() { return state == THREAD_COMPLETED; }
 
+       /** @return True if this thread is blocked */
+       bool is_blocked() { return state == THREAD_BLOCKED; }
+
        /** @return True if no threads are waiting on this Thread */
        bool wait_list_empty() { return wait_list.empty(); }