diff options
Diffstat (limited to 'src/rt/rust_kernel.cpp')
| -rw-r--r-- | src/rt/rust_kernel.cpp | 24 |
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; { |
