pub fn parallelize<T, F>(
thread_pool: &mut ThreadPool,
data: &mut [T],
func: F,
) -> usize
Expand description
Runs the function on multiple threads, splitting the data into one part for each thread.
The function also gets the offset of the specific subslice it got, relative
to the start of data
.
The return value is the size of the chunks data
was split into. The same
slices can be acquired by calling chunks
or chunks_mut
on data
and
passing it in as the chunk size. If the input slice is empty, 0 is returned.
§Panics
If the thread pool already has pending tasks. This shouldn’t ever be the case when using the threadpool with just this function, as this function always consumes all tasks it spawns.