about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-01-15 19:53:35 -0800
committerBrian Anderson <banderson@mozilla.com>2013-01-23 17:35:31 -0800
commit8852279a9ecac970e30b6d92d7efdcbd5485769c (patch)
tree53a3e26fe5cf72ea12ecac35664db7e70f85eeed /src/rt/rust_kernel.cpp
parent1bf8e579436941a82e4a4806b74dfd27ed4d1d74 (diff)
downloadrust-8852279a9ecac970e30b6d92d7efdcbd5485769c.tar.gz
rust-8852279a9ecac970e30b6d92d7efdcbd5485769c.zip
core: Add new weak task API
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 9c6ba9dcda3..d270ac07633 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -377,17 +377,12 @@ rust_kernel::weaken_task(rust_port_id chan) {
         KLOG_("Weakening task with channel %" PRIdPTR, chan);
         weak_task_chans.push_back(chan);
     }
-    uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
-    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
-    if (new_non_weak_tasks == 0) {
-        begin_shutdown();
-    }
+    inc_weak_task_count();
 }
 
 void
 rust_kernel::unweaken_task(rust_port_id chan) {
-    uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks);
-    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
+    dec_weak_task_count();
     {
         scoped_lock with(weak_task_lock);
         KLOG_("Unweakening task with channel %" PRIdPTR, chan);
@@ -400,6 +395,21 @@ rust_kernel::unweaken_task(rust_port_id chan) {
 }
 
 void
+rust_kernel::inc_weak_task_count() {
+    uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
+    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
+    if (new_non_weak_tasks == 0) {
+        begin_shutdown();
+    }
+}
+
+void
+rust_kernel::dec_weak_task_count() {
+    uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks);
+    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
+}
+
+void
 rust_kernel::end_weak_tasks() {
     std::vector<rust_port_id> chancopies;
     {