threads: assert THREAD_COMPLETED is immutable
authorBrian Norris <banorris@uci.edu>
Tue, 9 Oct 2012 17:42:50 +0000 (10:42 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 18 Dec 2012 22:58:32 +0000 (14:58 -0800)
threads-model.h
threads.cc

index 9a4d959..344d58b 100644 (file)
@@ -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; }
index 6b4e2c7..87de32f 100644 (file)
@@ -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;
+}