Skip to main content

ConcurrencyExecutor

Trait ConcurrencyExecutor 

Source
pub trait ConcurrencyExecutor: Send + Sync {
    // Required methods
    fn execute_batch<'life0, 'async_trait, F, T>(
        &'life0 self,
        items: Vec<T>,
        op: F,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(), ExecutionError>>, ExecutionError>> + Send + 'async_trait>>
       where F: Fn(T) -> Result<(), ExecutionError> + Send + Sync + 'static + 'async_trait,
             T: Send + 'static + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;
}
Expand description

Unified interface for concurrent batch execution.

Implementations provide different parallelism strategies:

  • Rayon: CPU-bound parallelism (multi-threaded)
  • Tokio: I/O-bound concurrency (async tasks)
  • Sequential: Single-threaded fallback

Required Methods§

Source

fn execute_batch<'life0, 'async_trait, F, T>( &'life0 self, items: Vec<T>, op: F, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(), ExecutionError>>, ExecutionError>> + Send + 'async_trait>>
where F: Fn(T) -> Result<(), ExecutionError> + Send + Sync + 'static + 'async_trait, T: Send + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Execute operation on batch of items concurrently.

Returns vector of results in same order as input items. Individual item failures don’t stop processing of other items.

§Arguments
  • items - Batch of items to process
  • op - Operation to apply to each item
§Returns

Vector of results for each item. Length matches input items.

§Errors

Returns error if batch execution infrastructure fails. Individual item failures are captured in result vector.

Source

fn name(&self) -> &str

Get executor implementation name for debugging.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§