From: Brian Norris Date: Thu, 6 Sep 2012 20:10:11 +0000 (-0700) Subject: threads: add is_complete() helper function X-Git-Tag: pldi2013~235^2^2~8 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=889c191994ae00a058bb71e24de95842f6454c0d threads: add is_complete() helper function --- diff --git a/threads.cc b/threads.cc index b3a1d55..a939592 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 e7cd792..f7efcf9 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