pub struct ConcurrentExecutor { /* private fields */ }Expand description
Executor for running concurrent tasks with controlled parallelism.
Implementations§
Source§impl ConcurrentExecutor
impl ConcurrentExecutor
Sourcepub fn new(config: ConcurrencyConfig) -> Self
pub fn new(config: ConcurrencyConfig) -> Self
Create a new concurrent executor.
Sourcepub async fn execute_all<T, F, Fut>(
&self,
tasks: impl IntoIterator<Item = F>,
) -> (Vec<TaskResult<T>>, ExecutionStats)
pub async fn execute_all<T, F, Fut>( &self, tasks: impl IntoIterator<Item = F>, ) -> (Vec<TaskResult<T>>, ExecutionStats)
Execute all tasks concurrently with controlled parallelism.
Tasks are started immediately but limited by the semaphore to ensure
at most max_concurrency tasks run at once.
Sourcepub async fn execute_collect<T, F, Fut>(
&self,
tasks: impl IntoIterator<Item = F>,
) -> (Vec<T>, Vec<TaskError>)
pub async fn execute_collect<T, F, Fut>( &self, tasks: impl IntoIterator<Item = F>, ) -> (Vec<T>, Vec<TaskError>)
Execute tasks and collect only successful results.
Returns the values in the same order as the input tasks.
Sourcepub async fn execute_indexed<T, F, Fut>(
&self,
tasks: impl IntoIterator<Item = F>,
) -> HashMap<usize, Result<T, TaskError>>
pub async fn execute_indexed<T, F, Fut>( &self, tasks: impl IntoIterator<Item = F>, ) -> HashMap<usize, Result<T, TaskError>>
Execute tasks with indexed results.
Returns a map of task_id -> result, useful when you need to correlate results with their original indices.
Auto Trait Implementations§
impl Freeze for ConcurrentExecutor
impl !RefUnwindSafe for ConcurrentExecutor
impl Send for ConcurrentExecutor
impl Sync for ConcurrentExecutor
impl Unpin for ConcurrentExecutor
impl !UnwindSafe for ConcurrentExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more