Skip to main content

run

Function run 

Source
pub fn run<T, R, F>(jobs: Jobs, items: &[T], work: F) -> Vec<R>
where T: Sync, R: Send, F: Fn(usize, &T) -> R + Sync,
Expand description

Runs work over every item, and returns the results in input order.

The closure runs on several threads at once and may finish in any order. The vector that comes back does not depend on that order, on the thread count, or on timing, which is the property spec/03-architecture.md section 3.7 requires and the reason this function exists rather than each caller reaching for threads directly.

A panic in the closure propagates once every other job has finished, rather than leaving the compilation half done with no diagnostic.

ยงPanics

Panics if work panicked on any item.