Expand description
Structured concurrency scopes for async tasks.
A Scope lets you spawn futures that borrow from the enclosing stack
frame, analogous to std::thread::scope. Unlike thread scope, the
tasks are driven cooperatively by the scope’s own future, they make
progress whenever the scope is polled so no runtime-level spawn is
involved and no unsafe is needed to extend lifetimes.
The scope function is the entry point. Inside the async closure,
call Scope::spawn to enqueue a task; the returned ScopedJoinHandle
resolves with the task’s output. Any tasks still running when the user
closure’s future completes are drained before scope returns, so every
borrow is released before the stack frame goes away.
Structs§
- Scope
- A scope within which tasks can be spawned that borrow from the enclosing stack frame.
- Scope
Executor - An
Executorwrapper that tracks spawned tasks so they can be canceled when a scope ends. - Scoped
Join Handle - A handle to a task spawned on a
Scope.
Functions§
- executor_
scope - Run an async closure with a scoped
Executorwrapper. - scope
- Create a scope for spawning tasks that borrow from the enclosing stack frame.