pub struct ParallelBatchProcessorBuilder<Item> { /* private fields */ }Expand description
Builder for ParallelBatchProcessor.
Use the builder when the default worker count, sequential fallback threshold, progress interval, or reporter should be customized.
use qubit_batch::ParallelBatchProcessor;
let processor = ParallelBatchProcessor::builder(|_item: &i32| {})
.thread_count(2)
.sequential_threshold(0)
.build()
.expect("parallel processor configuration should be valid");
assert_eq!(processor.thread_count(), 2);
assert_eq!(processor.sequential_threshold(), 0);Implementations§
Source§impl<Item> ParallelBatchProcessorBuilder<Item>
impl<Item> ParallelBatchProcessorBuilder<Item>
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 time between due-based running progress callbacks.Duration::ZEROreports at every sequential between-item progress point or on parallel worker completion signals without periodic polling.
§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<ParallelBatchProcessor<Item>, ParallelBatchProcessorBuildError>
pub fn build( self, ) -> Result<ParallelBatchProcessor<Item>, ParallelBatchProcessorBuildError>
Builds a validated ParallelBatchProcessor.
§Returns
A parallel batch processor when the configuration is valid.
§Errors
Returns ParallelBatchProcessorBuildError when the worker count is
zero.
Auto Trait Implementations§
impl<Item> Freeze for ParallelBatchProcessorBuilder<Item>
impl<Item> !RefUnwindSafe for ParallelBatchProcessorBuilder<Item>
impl<Item> Send for ParallelBatchProcessorBuilder<Item>
impl<Item> Sync for ParallelBatchProcessorBuilder<Item>
impl<Item> Unpin for ParallelBatchProcessorBuilder<Item>
impl<Item> UnsafeUnpin for ParallelBatchProcessorBuilder<Item>
impl<Item> !UnwindSafe for ParallelBatchProcessorBuilder<Item>
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