pub fn in_parallel_with_slice<I, S, R, E>(
input: &mut [I],
thread_limit: Option<usize>,
new_thread_state: impl FnMut(usize) -> S + Send + Clone,
consume: impl FnMut(&mut I, &mut S) -> Result<(), E> + Send + Clone,
periodic: impl FnMut() -> Option<Duration> + Send,
state_to_rval: impl FnOnce(S) -> R + Send + Clone,
) -> Result<Vec<R>, E>
Available on crate feature
parallel
only.Expand description
An experiment to have fine-grained per-item parallelization with built-in aggregation via thread state.
This is only good for operations where near-random access isn’t detrimental, so it’s not usually great
for file-io as it won’t make use of sorted inputs well.
Note that periodic
is not guaranteed to be called in case other threads come up first and finish too fast.