pub fn scope_and_block<'env, F, R>(
number_of_tasks: usize,
f: F,
) -> impl Iterator<Item = R>
Expand description
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.
Be aware that although this function avoids starving other independently spawned tasks, any
other code running concurrently in the same task will be suspended during the call to
block_in_place. This can happen e.g. when using the join!
macro. To avoid this issue, call
scope_and_block
in spawn_blocking
.