From 8852279a9ecac970e30b6d92d7efdcbd5485769c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 15 Jan 2013 19:53:35 -0800 Subject: core: Add new weak task API --- src/rt/rust_kernel.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/rt/rust_kernel.cpp') 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); @@ -399,6 +394,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 chancopies; -- cgit 1.4.1-3-g733a5