summaryrefslogtreecommitdiffstats
path: root/src/pipeline/dispatch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipeline/dispatch.rs')
-rw-r--r--src/pipeline/dispatch.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs
index 88f300e..89a8788 100644
--- a/src/pipeline/dispatch.rs
+++ b/src/pipeline/dispatch.rs
@@ -28,7 +28,7 @@ impl Pool {
handles.push(
std::thread::Builder::new()
.name(format!("worker-{n}"))
- .spawn(move || worker(cfg, db, rx, stop))
+ .spawn(crate::time::inherit(move || worker(cfg, db, rx, stop)))
.expect("spawn worker"),
);
}
@@ -40,7 +40,7 @@ impl Pool {
handles.push(
std::thread::Builder::new()
.name("dispatcher".into())
- .spawn(move || dispatcher(cfg2, db2, stop2, tx))
+ .spawn(crate::time::inherit(move || dispatcher(cfg2, db2, stop2, tx)))
.expect("spawn dispatcher"),
);
@@ -58,10 +58,12 @@ impl Pool {
fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String>) {
while !stop.load(Ordering::SeqCst) {
dispatch_once(&cfg, &db, &tx);
- let mut slept = 0u64;
- while slept < cfg.dispatch_tick_secs && !stop.load(Ordering::SeqCst) {
- std::thread::sleep(std::time::Duration::from_millis(200));
- slept += 1;
+ if !crate::time::wait(
+ std::time::Duration::from_secs(cfg.dispatch_tick_secs),
+ std::time::Duration::from_millis(200),
+ &stop,
+ ) {
+ break;
}
}
}