Skip to main content

Module scope_bounded

Module scope_bounded 

Source
Expand description

Bounded scoped parallelism: the number of tasks is known before the scope starts.

scope_bounded takes that count up front, hands the caller a Scope to spawn each task onto, and returns their results as an iterator. Tasks are closures and may borrow from the enclosing scope ('env); the scope blocks until every one has finished, which is what makes those borrows sound.

Use scope_unbounded instead when a running job can discover more work, so the total isn’t known up front.

Structs§

Scope
Scope to allow spawning tasks with a limited lifetime.

Functions§

scope_bounded
Helper method to spawn tasks in parallel, ensuring that all tasks are awaited and errors are handled. Also ensures turbo tasks and tracing context are maintained across the tasks.