threads: add is_complete() helper function
authorBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:10:11 +0000 (13:10 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:10:11 +0000 (13:10 -0700)
threads.cc
threads.h

index b3a1d5599fb541d340184e0e2ba0f7589c0ec5ae..a9395926816f38bc4872019a3047357574c1e2b9 100644 (file)
@@ -104,7 +104,7 @@ int Thread::swap(ucontext_t *ctxt, Thread *t)
 /** Terminate a thread and free its stack. */
 void Thread::complete()
 {
-       if (state != THREAD_COMPLETED) {
+       if (!is_complete()) {
                DEBUG("completed thread %d\n", get_id());
                state = THREAD_COMPLETED;
                if (stack)
index e7cd792a134c4b5e223b6f9465af4eaf83753b1e..f7efcf967236b4c57ed22440ffa16a49bca1c5be 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -67,6 +67,9 @@ public:
         */
        uint64_t get_return_value() { return last_action_val; }
 
+       /** @return True if this thread is finished executing */
+       bool is_complete() { return state == THREAD_COMPLETED; }
+
        friend void thread_startup();
 
        SNAPSHOTALLOC