about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <mbebenita@mozilla.com>2010-07-28 14:45:44 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-07-28 20:30:29 -0700
commit5db5eb0c55ff303db96390a4bf6a5365382cc357 (patch)
tree2d0d68e4c4ee0cb285a13f899214ca47ec14d526 /src/rt/rust_task.cpp
parente327aa50931b8d081598a47dc8e085a2f52f851f (diff)
downloadrust-5db5eb0c55ff303db96390a4bf6a5365382cc357.tar.gz
rust-5db5eb0c55ff303db96390a4bf6a5365382cc357.zip
Null rust_task::cond on wakeup, add asserts and logging to block/wakeup.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 6f96ac916c8..2bb0954196e 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -529,23 +529,29 @@ rust_task::transition(ptr_vec<rust_task> *src, ptr_vec<rust_task> *dst)
 void
 rust_task::block(rust_cond *on)
 {
-    I(dom, on);
+    log(rust_log::TASK, "Blocking on 0x%" PRIxPTR ", cond: 0x%" PRIxPTR,
+                         (uintptr_t) on, (uintptr_t) cond);
+    A(dom, cond == NULL, "Cannot block an already blocked task.");
+    A(dom, on != NULL, "Cannot block on a NULL object.");
+
     transition(&dom->running_tasks, &dom->blocked_tasks);
-    dom->log(rust_log::TASK,
-             "task 0x%" PRIxPTR " blocking on 0x%" PRIxPTR,
-             (uintptr_t)this,
-             (uintptr_t)on);
     cond = on;
 }
 
 void
 rust_task::wakeup(rust_cond *from)
 {
+    A(dom, cond != NULL, "Cannot wake up unblocked task.");
+    log(rust_log::TASK, "Blocked on 0x%" PRIxPTR " woken up on 0x%" PRIxPTR,
+                        (uintptr_t) cond, (uintptr_t) from);
+    A(dom, cond == from, "Cannot wake up blocked task on wrong condition.");
+
     transition(&dom->blocked_tasks, &dom->running_tasks);
     // TODO: Signaling every time the task is awaken is kind of silly,
     // do this a nicer way.
     dom->_progress.signal();
     I(dom, cond == from);
+    cond = NULL;
 }
 
 void