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 9a4d959ddd8d380c2562d624b97fc8059f315444..344d58badada9f13297a149c220c0f33d505238a 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 6b4e2c740ab50b7b55f624b7bda05a4c9ad72678..87de32fb2452f0384016353306b0b0b43c3d4cea 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;
+}