use std::{
sync::Arc,
time::Duration,
};
use qubit_progress::reporter::{
NoOpProgressReporter,
ProgressReporter,
};
use super::SequentialBatchExecutor;
pub struct SequentialBatchExecutorBuilder {
report_interval: Duration,
reporter: Arc<dyn ProgressReporter>,
}
impl SequentialBatchExecutorBuilder {
#[inline]
pub const fn report_interval(mut self, report_interval: Duration) -> Self {
self.report_interval = report_interval;
self
}
#[inline]
pub fn reporter<R>(mut self, reporter: R) -> Self
where
R: ProgressReporter + 'static,
{
self.reporter = Arc::new(reporter);
self
}
#[inline]
pub fn reporter_arc(mut self, reporter: Arc<dyn ProgressReporter>) -> Self {
self.reporter = reporter;
self
}
#[inline]
pub fn no_reporter(mut self) -> Self {
self.reporter = Arc::new(NoOpProgressReporter);
self
}
#[inline]
pub fn build(self) -> SequentialBatchExecutor {
SequentialBatchExecutor {
report_interval: self.report_interval,
reporter: self.reporter,
}
}
}
impl Default for SequentialBatchExecutorBuilder {
fn default() -> Self {
Self {
report_interval: SequentialBatchExecutor::DEFAULT_REPORT_INTERVAL,
reporter: Arc::new(NoOpProgressReporter),
}
}
}