From: Brian Norris Date: Thu, 6 Sep 2012 20:10:11 +0000 (-0700) Subject: threads: add is_complete() helper function X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=889c191994ae00a058bb71e24de95842f6454c0d;hp=f472540b6ab3b65c91221f6f0790d8327333a5c2;p=c11tester.git threads: add is_complete() helper function --- diff --git a/threads.cc b/threads.cc index b3a1d559..a9395926 100644 --- a/threads.cc +++ b/threads.cc @@ -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) diff --git a/threads.h b/threads.h index e7cd792a..f7efcf96 100644 --- 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