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 b3a1d55..a939592 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 e7cd792..f7efcf9 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