pub struct SequentialBatchExecutor { /* private fields */ }Expand description
Executes a whole batch sequentially on the caller thread.
Progress updates are emitted only between tasks. A long-running single task therefore does not produce intermediate sequential progress callbacks.
use qubit_batch::{
BatchExecutor,
SequentialBatchExecutor,
};
let outcome = SequentialBatchExecutor::new()
.for_each(["a", "b", "c"], |item| {
assert!(!item.is_empty());
Ok::<(), &'static str>(())
})
.expect("array length should be exact");
assert!(outcome.is_success());Implementations§
Source§impl SequentialBatchExecutor
impl SequentialBatchExecutor
Sourcepub const DEFAULT_REPORT_INTERVAL: Duration
pub const DEFAULT_REPORT_INTERVAL: Duration
Default interval between progress callbacks.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a sequential batch executor with default configuration.
§Returns
A sequential batch executor using no-op progress reporting.
Sourcepub fn builder() -> SequentialBatchExecutorBuilder
pub fn builder() -> SequentialBatchExecutorBuilder
Creates a builder for configuring a sequential batch executor.
§Returns
A builder initialized with default settings.
Sourcepub const fn report_interval(&self) -> Duration
pub const fn report_interval(&self) -> Duration
Returns the configured progress-report interval.
§Returns
The minimum time between due-based running progress callbacks.
Sourcepub fn reporter(&self) -> &Arc<dyn ProgressReporter>
pub fn reporter(&self) -> &Arc<dyn ProgressReporter>
Returns the progress reporter used by this executor.
§Returns
A shared reference to the configured progress reporter.
Trait Implementations§
Source§impl BatchExecutor for SequentialBatchExecutor
impl BatchExecutor for SequentialBatchExecutor
Source§fn execute_with_count<T, E, I>(
&self,
tasks: I,
count: usize,
) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
fn execute_with_count<T, E, I>( &self, tasks: I, count: usize, ) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
Executes the batch sequentially on the caller thread.
§Parameters
tasks- Task source for the batch.count- Declared task count expected fromtasks.
§Returns
A structured batch result when the declared task count matches, or a batch-count mismatch error with the attached partial result.
§Errors
Returns BatchExecutionError when tasks yields fewer or more tasks
than count.
§Panics
Panics from tasks are captured in the result. Panics from the configured progress reporter are propagated to the caller.
Source§fn execute<T, E, I>(
&self,
tasks: I,
) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
fn execute<T, E, I>( &self, tasks: I, ) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
Source§fn call<C, R, E, I>(
&self,
tasks: I,
) -> Result<BatchCallResult<R, E>, BatchExecutionError<E>>where
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
C: Callable<R, E> + Send,
R: Send,
E: Send,
fn call<C, R, E, I>(
&self,
tasks: I,
) -> Result<BatchCallResult<R, E>, BatchExecutionError<E>>where
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
C: Callable<R, E> + Send,
R: Send,
E: Send,
Source§fn call_with_count<C, R, E, I>(
&self,
tasks: I,
count: usize,
) -> Result<BatchCallResult<R, E>, BatchExecutionError<E>>
fn call_with_count<C, R, E, I>( &self, tasks: I, count: usize, ) -> Result<BatchCallResult<R, E>, BatchExecutionError<E>>
Source§fn for_each<Item, E, I, F>(
&self,
items: I,
action: F,
) -> Result<BatchOutcome<E>, BatchExecutionError<E>>where
I: IntoIterator<Item = Item>,
I::IntoIter: ExactSizeIterator,
Item: Send,
F: Fn(Item) -> Result<(), E> + Send + Sync,
E: Send,
fn for_each<Item, E, I, F>(
&self,
items: I,
action: F,
) -> Result<BatchOutcome<E>, BatchExecutionError<E>>where
I: IntoIterator<Item = Item>,
I::IntoIter: ExactSizeIterator,
Item: Send,
F: Fn(Item) -> Result<(), E> + Send + Sync,
E: Send,
action to every item whose iterator exposes an exact length. Read moreSource§fn for_each_with_count<Item, E, I, F>(
&self,
items: I,
count: usize,
action: F,
) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
fn for_each_with_count<Item, E, I, F>( &self, items: I, count: usize, action: F, ) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
action to every item using an explicit declared count. Read moreSource§impl Clone for SequentialBatchExecutor
impl Clone for SequentialBatchExecutor
Source§fn clone(&self) -> SequentialBatchExecutor
fn clone(&self) -> SequentialBatchExecutor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more