Skip to main content

run_concurrent_batch_with_progress

Function run_concurrent_batch_with_progress 

Source
pub async fn run_concurrent_batch_with_progress<T, R, F, Fut, P>(
    items: Vec<T>,
    concurrency: usize,
    job_fn: impl Fn(T) -> Fut + Send + Sync + Clone + 'static,
    progress_fn: impl Fn(usize, &R) + Send + Sync + Clone + 'static,
) -> Vec<R>
where T: Send + 'static, R: Send + 'static, F: FnOnce(T) -> Fut + Send + Sync + Clone + 'static, Fut: Future<Output = R> + Send, P: Fn(usize, &R) + Send + Sync + Clone + 'static,
Expand description

Runs a batch of operations with progress reporting.

Similar to run_concurrent_batch, but also reports progress through a callback function. This is useful for long-running operations where you want to update a progress bar or log periodic status updates.

§Type Parameters

  • T - The input item type
  • R - The result type
  • F - The function type that processes each item
  • Fut - The future type returned by the function
  • P - The progress callback function type

§Arguments

  • items - Vector of items to process
  • concurrency - Maximum number of concurrent operations
  • job_fn - Function that processes each item and returns a future
  • progress_fn - Callback function called after each item is processed

§Returns

A vector containing the results of all operations in the same order as the input items.