about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-04 00:03:45 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-04 00:31:43 -0800
commit9fa950ec53dc7428d2d4a20ba56a50c21d5606a5 (patch)
treebe3fb16701844926dedc6b60d36ced2d1360ea25 /src/rt/rust_kernel.cpp
parent21d783c33844028d8baa0d4d022fc244fc3ba77b (diff)
downloadrust-9fa950ec53dc7428d2d4a20ba56a50c21d5606a5.tar.gz
rust-9fa950ec53dc7428d2d4a20ba56a50c21d5606a5.zip
rt: Stop using atomic ops on rust_kernel::live_tasks
These ops are all done within spitting distance of a suitable lock,
so just protect it with the lock.
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 367b76a9136..33191c2f553 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -84,25 +84,27 @@ rust_kernel::fail() {
 
 void
 rust_kernel::register_task(rust_task *task) {
+    int new_live_tasks;
     {
         scoped_lock with(task_lock);
         task->user.id = max_task_id++;
         task_table.put(task->user.id, task);
+        new_live_tasks = ++live_tasks;
     }
     K(srv, task->user.id != INTPTR_MAX, "Hit the maximum task id");
     KLOG_("Registered task %" PRIdPTR, task->user.id);
-    int new_live_tasks = sync::increment(live_tasks);
     KLOG_("Total outstanding tasks: %d", new_live_tasks);
 }
 
 void
 rust_kernel::release_task_id(rust_task_id id) {
     KLOG_("Releasing task %" PRIdPTR, id);
+    int new_live_tasks;
     {
         scoped_lock with(task_lock);
         task_table.remove(id);
+        new_live_tasks = --live_tasks;
     }
-    int new_live_tasks = sync::decrement(live_tasks);
     KLOG_("Total outstanding tasks: %d", new_live_tasks);
     if (new_live_tasks == 0) {
         // There are no more tasks and there never will be.