Skip to main content

parallel_scan

Function parallel_scan 

Source
pub fn parallel_scan<T, U, F>(
    input: &[T],
    chunk_count: usize,
    worker: F,
) -> Vec<U>
where T: Send + Sync + Clone + 'static, U: Send + 'static, F: Fn(&[T]) -> Vec<U> + Send + Sync + 'static,
Expand description

Execute worker across input in parallel using chunk_count threads. Preserves input order in the output: chunk 0’s results come first, chunk 1’s next, etc.

  • T — the input row type. Must be Send + Sync so chunks can be passed to worker threads.
  • U — the output row type from a single worker. Must be Send.
  • F — the worker closure. Must be Send + Sync + 'static and take a slice reference to the chunk.

Falls back to sequential execution when the input is smaller than MIN_PARALLEL_ROWS or when chunk_count <= 1.