Skip to main content

SequentialBatchExecutor

Struct SequentialBatchExecutor 

Source
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

Source

pub const DEFAULT_REPORT_INTERVAL: Duration

Default interval between progress callbacks.

Source

pub fn new() -> Self

Creates a sequential batch executor with default configuration.

§Returns

A sequential batch executor using no-op progress reporting.

Source

pub fn builder() -> SequentialBatchExecutorBuilder

Creates a builder for configuring a sequential batch executor.

§Returns

A builder initialized with default settings.

Source

pub const fn report_interval(&self) -> Duration

Returns the configured progress-report interval.

§Returns

The minimum time between due-based running progress callbacks.

Source

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

Source§

fn execute_with_count<T, E, I>( &self, tasks: I, count: usize, ) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
where I: IntoIterator<Item = T>, T: Runnable<E> + Send, E: Send,

Executes the batch sequentially on the caller thread.

§Parameters
  • tasks - Task source for the batch.
  • count - Declared task count expected from tasks.
§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>>
where I: IntoIterator<Item = T>, I::IntoIter: ExactSizeIterator, T: Runnable<E> + Send, E: Send,

Executes a batch of runnable tasks whose iterator exposes an exact length. Read more
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,

Executes callable tasks whose iterator exposes an exact length. Read more
Source§

fn call_with_count<C, R, E, I>( &self, tasks: I, count: usize, ) -> Result<BatchCallResult<R, E>, BatchExecutionError<E>>
where I: IntoIterator<Item = C>, C: Callable<R, E> + Send, R: Send, E: Send,

Executes callable tasks with an explicit declared count and collects success values by index. Read more
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,

Applies action to every item whose iterator exposes an exact length. Read more
Source§

fn for_each_with_count<Item, E, I, F>( &self, items: I, count: usize, action: F, ) -> Result<BatchOutcome<E>, BatchExecutionError<E>>
where I: IntoIterator<Item = Item>, Item: Send, F: Fn(Item) -> Result<(), E> + Send + Sync, E: Send,

Applies action to every item using an explicit declared count. Read more
Source§

impl Clone for SequentialBatchExecutor

Source§

fn clone(&self) -> SequentialBatchExecutor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SequentialBatchExecutor

Source§

fn default() -> Self

Creates a sequential batch executor with default configuration.

§Returns

A sequential batch executor using no-op progress reporting.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.