Skip to main content

scope

Function scope 

Source
pub async fn scope<'env, TaskResult, Closure, ClosureResult>(
    closure: Closure,
) -> ClosureResult
where TaskResult: Send + 'env, Closure: for<'s> AsyncFnOnce(&'s mut Scope<'s, 'env, TaskResult>) -> ClosureResult,
Expand description

Creates a scope for spawning non-'static futures.

The provided closure receives a Scope handle which can be used to spawn tasks. The scope guarantees that all spawned tasks will be joined or aborted before the function returns.

ยงCancellation Safety

This future is not cancellation safe. If the future returned by this function is dropped before it completes (e.g., by wrapping it in tokio::time::timeout or tokio::select!), the process will be aborted (via std::process::abort).