Skip to main content

ParallelBatchExecutorBuilder

Struct ParallelBatchExecutorBuilder 

Source
pub struct ParallelBatchExecutorBuilder { /* private fields */ }
Expand description

Builder for ParallelBatchExecutor.

Use the builder when the default worker count, sequential fallback threshold, progress interval, or reporter should be customized.

use qubit_batch::ParallelBatchExecutor;

let executor = ParallelBatchExecutor::builder()
    .thread_count(2)
    .sequential_threshold(0)
    .build()
    .expect("parallel executor configuration should be valid");

assert_eq!(executor.thread_count(), 2);
assert_eq!(executor.sequential_threshold(), 0);

Implementations§

Source§

impl ParallelBatchExecutorBuilder

Source

pub const fn thread_count(self, thread_count: usize) -> Self

Sets the worker-thread count.

§Parameters
  • thread_count - Number of scoped worker threads to use.
§Returns

This builder for fluent configuration.

Source

pub const fn sequential_threshold(self, sequential_threshold: usize) -> Self

Sets the sequential fallback threshold.

§Parameters
  • sequential_threshold - Maximum batch size that still runs sequentially.
§Returns

This builder for fluent configuration.

Source

pub const fn report_interval(self, report_interval: Duration) -> Self

Sets the progress-report interval.

§Parameters
  • report_interval - Minimum interval between due-based running progress events. Use Duration::ZERO to report at every implementation-defined running progress point.
§Returns

This builder for fluent configuration.

Source

pub fn reporter<R>(self, reporter: R) -> Self
where R: ProgressReporter + 'static,

Sets the progress reporter used by built executors.

§Parameters
  • reporter - Reporter receiving batch lifecycle callbacks.
§Returns

This builder for fluent configuration.

Source

pub fn reporter_arc(self, reporter: Arc<dyn ProgressReporter>) -> Self

Sets the shared progress reporter used by built executors.

§Parameters
  • reporter - Shared reporter receiving batch lifecycle callbacks.
§Returns

This builder for fluent configuration.

Source

pub fn no_reporter(self) -> Self

Disables progress callbacks by using NoOpProgressReporter.

§Returns

This builder for fluent configuration.

Source

pub fn build( self, ) -> Result<ParallelBatchExecutor, ParallelBatchExecutorBuildError>

Builds a validated ParallelBatchExecutor.

§Returns

A parallel batch executor when the configuration is valid.

§Errors

Returns ParallelBatchExecutorBuildError when the worker count is zero.

Trait Implementations§

Source§

impl Default for ParallelBatchExecutorBuilder

Source§

fn default() -> Self

Creates a builder with default parallel batch settings.

§Returns

A builder using available parallelism, five-second progress intervals, sequential fallback for batches at or below ParallelBatchExecutor::DEFAULT_SEQUENTIAL_THRESHOLD, and no-op 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> 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, 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.