summary refs log tree commit diff
path: root/src/rt/rust_task_thread.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-03-17 18:19:49 -0700
committerBrian Anderson <banderson@mozilla.com>2012-03-18 18:18:15 -0700
commit47c18957242e34ddb8b12f27c8efd396171fef6d (patch)
treed0225a9073c770e61dbe8e71050cf9223306e9a5 /src/rt/rust_task_thread.cpp
parent05466c61380366cfd1969bb9f4eb26cff2acaedd (diff)
downloadrust-47c18957242e34ddb8b12f27c8efd396171fef6d.tar.gz
rust-47c18957242e34ddb8b12f27c8efd396171fef6d.zip
rt: Don't store the name of the task state in rust_task_list
Diffstat (limited to 'src/rt/rust_task_thread.cpp')
-rw-r--r--src/rt/rust_task_thread.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp
index 0388d48c906..6997309fee3 100644
--- a/src/rt/rust_task_thread.cpp
+++ b/src/rt/rust_task_thread.cpp
@@ -27,10 +27,10 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched,
     id(id),
     should_exit(false),
     cached_c_stack(NULL),
-    newborn_tasks(this, "newborn"),
-    running_tasks(this, "running"),
-    blocked_tasks(this, "blocked"),
-    dead_tasks(this, "dead"),
+    newborn_tasks(this),
+    running_tasks(this),
+    blocked_tasks(this),
+    dead_tasks(this),
     kernel(sched->kernel),
     sched(sched),
     srv(srv),
@@ -248,7 +248,7 @@ rust_task_thread::start_main_loop() {
              ", state: %s",
              scheduled_task->name,
              (uintptr_t)scheduled_task,
-             state_list(scheduled_task->get_state())->name);
+             state_name(scheduled_task->get_state()));
 
         place_task_in_tls(scheduled_task);
 
@@ -262,7 +262,7 @@ rust_task_thread::start_main_loop() {
              " in state '%s', worker id=%d" PRIxPTR,
              scheduled_task->name,
              (uintptr_t)scheduled_task,
-             state_list(scheduled_task->get_state())->name,
+             state_name(scheduled_task->get_state()),
              id);
 
         reap_dead_tasks();
@@ -316,20 +316,35 @@ rust_task_thread::state_list(rust_task_state state) {
     }
 }
 
+const char *
+rust_task_thread::state_name(rust_task_state state) {
+    switch (state) {
+    case task_state_newborn:
+        return "newborn";
+    case task_state_running:
+        return "running";
+    case task_state_blocked:
+        return "blocked";
+    case task_state_dead:
+        return "dead";
+    default:
+        assert(false);
+        return "";
+    }
+}
+
 void 
 rust_task_thread::transition(rust_task *task,
                              rust_task_state src, rust_task_state dst,
                              rust_cond *cond, const char* cond_name) {
     scoped_lock with(lock);
-    rust_task_list *src_list = state_list(src);
-    rust_task_list *dst_list = state_list(dst);
     DLOG(this, task,
          "task %s " PTR " state change '%s' -> '%s' while in '%s'",
-         name, (uintptr_t)this, src_list->name, dst_list->name,
-         state_list(task->get_state())->name);
+         name, (uintptr_t)this, state_name(src), state_name(dst),
+         state_name(task->get_state()));
     I(this, task->get_state() == src);
-    src_list->remove(task);
-    dst_list->append(task);
+    state_list(src)->remove(task);
+    state_list(dst)->append(task);
     task->set_state(dst, cond, cond_name);
 
     lock.signal();