about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-27 14:51:25 -0700
committerEric Holk <eholk@mozilla.com>2011-07-28 10:47:28 -0700
commit279844ce9fc64969d1c048335214627ab50237a0 (patch)
tree40156df61bc5df2bb3c1f1839f4afd65052db7e7 /src/rt/rust_task.cpp
parenta5fe66e7065c0e91064f3a818ea901ecfb499b70 (diff)
downloadrust-279844ce9fc64969d1c048335214627ab50237a0.tar.gz
rust-279844ce9fc64969d1c048335214627ab50237a0.zip
Atomic reference counting for tasks.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 05efc12e4d4..a144879cc04 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -64,7 +64,7 @@ size_t const callee_save_fp = 0;
 
 rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
                      rust_task *spawner, const char *name) :
-    maybe_proxy<rust_task>(this),
+    ref_count(1),
     stk(NULL),
     runtime_sp(0),
     rust_sp(0),
@@ -92,10 +92,6 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
 
     stk = new_stk(this, 0);
     rust_sp = stk->limit;
-
-    if (spawner == NULL) {
-        ref_count = 0;
-    }
 }
 
 rust_task::~rust_task()
@@ -131,10 +127,6 @@ void task_start_wrapper(spawn_args *a)
 
     LOG(task, task, "task exited with value %d", rval);
 
-
-    LOG(task, task, "task ref_count: %d", task->ref_count);
-    A(task->sched, task->ref_count >= 0,
-      "Task ref_count should not be negative on exit!");
     task->die();
     task->lock.lock();
     task->notify_tasks_waiting_to_join();
@@ -263,17 +255,10 @@ rust_task::notify_tasks_waiting_to_join() {
     while (tasks_waiting_to_join.is_empty() == false) {
         LOG(this, task, "notify_tasks_waiting_to_join: %d",
             tasks_waiting_to_join.size());
-        maybe_proxy<rust_task> *waiting_task = 0;
+        rust_task *waiting_task = 0;
         tasks_waiting_to_join.pop(&waiting_task);
-        if (waiting_task->is_proxy()) {
-            notify_message::send(notify_message::WAKEUP, "wakeup",
-                get_handle(), waiting_task->as_proxy()->handle());
-            delete waiting_task;
-        } else {
-            rust_task *task = waiting_task->referent();
-            if (task->blocked() == true) {
-                task->wakeup(this);
-            }
+        if (waiting_task->blocked() == true) {
+            waiting_task->wakeup(this);
         }
     }
 }