Skip to main content

scope_unbounded

Function scope_unbounded 

Source
pub fn scope_unbounded<'env, T, F>(initial: impl IntoIterator<Item = T>, run: F)
where T: Send + 'static, F: Fn(&Scope<'_, T, ()>, T) -> ControlFlow<()> + Send + Sync + 'env,
Expand description

Runs run over initial and everything it transitively spawns, returning once every item has been processed. No results are collected; jobs communicate through state captured in run. Use scope_unbounded_with to accumulate a value instead. Items must be 'static (they sit in a queue drained by other threads); the run closure may borrow 'env data.

ยงAborting

Both ControlFlow::Break and a panic abandon all queued-but-unstarted items, so the scope returns as soon as the currently-running jobs finish. Jobs already in flight on other threads are not interrupted in either case.