From: Brian Norris Date: Tue, 9 Oct 2012 17:42:50 +0000 (-0700) Subject: threads: assert THREAD_COMPLETED is immutable X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=a330eb33b1b62dfa71f3f0cb055367a30090c180 threads: assert THREAD_COMPLETED is immutable --- diff --git a/threads-model.h b/threads-model.h index 9a4d959d..344d58ba 100644 --- a/threads-model.h +++ b/threads-model.h @@ -44,7 +44,7 @@ public: static int swap(Thread *t, ucontext_t *ctxt); thread_state get_state() const { return state; } - void set_state(thread_state s) { state = s; } + void set_state(thread_state s); thread_id_t get_id() const; thrd_t get_thrd_t() const { return *user_thread; } Thread * get_parent() const { return parent; } diff --git a/threads.cc b/threads.cc index 6b4e2c74..87de32fb 100644 --- a/threads.cc +++ b/threads.cc @@ -178,3 +178,13 @@ thread_id_t Thread::get_id() const { return id; } + +/** + * Set a thread's THREAD_* state (@see thread_state) + * @param s The state to enter + */ +void Thread::set_state(thread_state s) +{ + ASSERT(s == THREAD_COMPLETED || state != THREAD_COMPLETED); + state = s; +}