core: Add new weak task API
This commit is contained in:
@@ -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<rust_port_id> chancopies;
|
||||
|
||||
Reference in New Issue
Block a user