Skip to main content

cancellable_task

Function cancellable_task 

Source
fn cancellable_task<R: Send + 'static>(
    f: impl FnOnce() -> R + Send + 'static,
    operation: &'static str,
) -> Result<(impl FnOnce() + Send + 'static, Receiver<Result<R>>), SpawnError>
Expand description

Builds a cancellable task closure and its receiver.

The closure wraps f with cooperative cancellation, panic catching, timing metrics, and slot tracking via guard.

Note: Cooperative cancellation only prevents “queued zombies” - tasks whose receiver was dropped before execution started. If the timeout fires after execution begins, the task will still run to completion (counted as “orphaned”).