Expand description
Concurrency abstraction layer for incremental analysis.
Provides unified interface for parallel execution across different deployment targets:
- RayonExecutor: CPU-bound parallelism for CLI (multi-core)
- TokioExecutor: Async I/O concurrency for all deployments
- SequentialExecutor: Fallback for single-threaded execution
§Architecture
The concurrency layer adapts to deployment context via feature flags:
- CLI with
parallelfeature: Rayon for CPU-bound work - All deployments: tokio for async I/O operations
- Fallback: Sequential execution when parallelism unavailable
§Examples
§Basic Usage
use thread_flow::incremental::concurrency::{
create_executor, ConcurrencyMode, ExecutionError,
};
// Create executor for current deployment
let executor = create_executor(ConcurrencyMode::Tokio { max_concurrent: 10 });
// Process batch of items
let items = vec![1, 2, 3, 4, 5];
let results = executor.execute_batch(items, |n| {
// Your work here
Ok(())
}).await?;
assert_eq!(results.len(), 5);§Feature-Aware Execution
use thread_flow::incremental::concurrency::{
create_executor, ConcurrencyMode,
};
// Automatically uses best executor for current build
#[cfg(feature = "parallel")]
let executor = create_executor(ConcurrencyMode::Rayon { num_threads: None });
#[cfg(not(feature = "parallel"))]
let executor = create_executor(ConcurrencyMode::Tokio { max_concurrent: 10 });Structs§
- Rayon
Executor - CPU-bound parallel executor using Rayon thread pool.
- Sequential
Executor - Sequential executor processing items one at a time.
- Tokio
Executor - Async I/O executor using tokio tasks with concurrency limit.
Enums§
- Concurrency
Mode - Concurrency mode selection for executor factory.
- Execution
Error - Errors that can occur during batch execution.
- Executor
- Unified executor enum combining all concurrency strategies.
Traits§
- Concurrency
Executor - Unified interface for concurrent batch execution.
Functions§
- create_
executor - Create executor instance based on mode and available features.