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
impl ParallelBatchExecutorBuilder
Sourcepub const fn thread_count(self, thread_count: usize) -> Self
pub const fn thread_count(self, thread_count: usize) -> Self
Sourcepub const fn sequential_threshold(self, sequential_threshold: usize) -> Self
pub const fn sequential_threshold(self, sequential_threshold: usize) -> Self
Sourcepub const fn report_interval(self, report_interval: Duration) -> Self
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. UseDuration::ZEROto report at every implementation-defined running progress point.
§Returns
This builder for fluent configuration.
Sourcepub fn reporter<R>(self, reporter: R) -> Selfwhere
R: ProgressReporter + 'static,
pub fn reporter<R>(self, reporter: R) -> Selfwhere
R: ProgressReporter + 'static,
Sourcepub fn reporter_arc(self, reporter: Arc<dyn ProgressReporter>) -> Self
pub fn reporter_arc(self, reporter: Arc<dyn ProgressReporter>) -> Self
Sourcepub fn no_reporter(self) -> Self
pub fn no_reporter(self) -> Self
Disables progress callbacks by using NoOpProgressReporter.
§Returns
This builder for fluent configuration.
Sourcepub fn build(
self,
) -> Result<ParallelBatchExecutor, ParallelBatchExecutorBuildError>
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
impl Default for ParallelBatchExecutorBuilder
Source§fn default() -> Self
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§
impl Freeze for ParallelBatchExecutorBuilder
impl !RefUnwindSafe for ParallelBatchExecutorBuilder
impl Send for ParallelBatchExecutorBuilder
impl Sync for ParallelBatchExecutorBuilder
impl Unpin for ParallelBatchExecutorBuilder
impl UnsafeUnpin for ParallelBatchExecutorBuilder
impl !UnwindSafe for ParallelBatchExecutorBuilder
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