From a330eb33b1b62dfa71f3f0cb055367a30090c180 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 9 Oct 2012 10:42:50 -0700 Subject: [PATCH] threads: assert THREAD_COMPLETED is immutable --- threads-model.h | 2 +- threads.cc | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/threads-model.h b/threads-model.h index 9a4d959..344d58b 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 6b4e2c7..87de32f 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; +} -- 2.34.1