Expand description
Batch file processing with optional parallel execution
This module provides utilities for processing multiple files efficiently:
- CLI builds (default): Uses rayon for CPU parallelism across cores
- Worker builds: Falls back to sequential processing (no threads in edge)
§Feature Gating
Parallel processing is controlled by the parallel feature flag:
- Enabled (default): Multi-core parallel processing via rayon
- Disabled (worker): Single-threaded sequential processing
§Usage
ⓘ
use thread_flow::batch::process_files_batch;
let results = process_files_batch(&file_paths, |path| {
// Process each file
analyze_file(path)
});§Performance Characteristics
| Target | Concurrency | 100 Files | 1000 Files |
|---|---|---|---|
| CLI (4 cores) | Parallel | ~0.4s | ~4s |
| CLI (1 core) | Sequential | ~1.6s | ~16s |
| Worker | Sequential | ~1.6s | ~16s |
Speedup: 2-4x on multi-core systems (linear with core count)
Functions§
- process_
batch - Process multiple items in batch with optional parallelism
- process_
files_ batch - Process multiple files in batch with optional parallelism
- try_
process_ files_ batch - Try to process multiple files in batch, collecting errors