pub fn parallel_batch_process<T, R, F>(
items: &[T],
config: &BatchConfig,
func: F,
) -> Result<BatchResult<R>>Expand description
Process a batch of items in parallel
This function processes multiple items in parallel, collecting both successes and failures. It provides thread-safe error handling and optional progress tracking.
§Arguments
items- Items to processconfig- Batch configurationfunc- Function to apply to each item
§Returns
Batch result containing successes and failures
§Example
use oxigdal_algorithms::parallel::{parallel_batch_process, BatchConfig};
let items = vec![1, 2, 3, 4, 5];
let config = BatchConfig::default();
let result = parallel_batch_process(&items, &config, |&item| {
Ok(item * 2)
});
match result {
Ok(batch_result) => {
println!("Success: {}/{}", batch_result.success_count(), batch_result.total);
}
Err(e) => eprintln!("Batch processing failed: {}", e),
}