diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 19:50:24 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 19:50:24 +0000 |
| commit | 768da4fd62b390014fcaf55e23dbb45ca61ad79b (patch) | |
| tree | d92601ec5ac16e37440b2dc13e06edd97f02e30f /src/watch/scheduler.rs | |
| parent | bc4916d4a7de6a60d8b73ed7e3ccc0ec0695d580 (diff) | |
| download | aur-build-768da4fd62b390014fcaf55e23dbb45ca61ad79b.tar.gz aur-build-768da4fd62b390014fcaf55e23dbb45ca61ad79b.zip | |
time: a wait seam the control loops call through
The dispatcher tick, watcher tick, SSE poll, agent watchdog and remote
keepalive each slept on the wall clock in their own slice loop, so every test
that wanted a tick waited for real time. They call crate::time::wait/sleep now,
which is the same real sleep in a production build and a virtual clock advance
under test-support: a test that takes the clock owns it, and threads it spawns
inherit it. production_surface checks the virtual path is compiled out and that
no control loop went back to std::thread::sleep.
Diffstat (limited to 'src/watch/scheduler.rs')
| -rw-r--r-- | src/watch/scheduler.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/watch/scheduler.rs b/src/watch/scheduler.rs index eb79db0..4508a03 100644 --- a/src/watch/scheduler.rs +++ b/src/watch/scheduler.rs @@ -9,17 +9,19 @@ use crate::watch::detect::check_pkgbase; pub fn spawn_scheduler(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>) -> JoinHandle<()> { std::thread::Builder::new() .name("watcher".into()) - .spawn(move || { + .spawn(crate::time::inherit(move || { while !stop.load(Ordering::SeqCst) { let tick = crate::db::setting_i64(&db, "poll_tick", 30); sweep(&cfg, &db); - let mut slept = 0; - while slept < tick && !stop.load(Ordering::SeqCst) { - std::thread::sleep(std::time::Duration::from_secs(1)); - slept += 1; + if !crate::time::wait( + std::time::Duration::from_secs(tick.max(0) as u64), + std::time::Duration::from_secs(1), + &stop, + ) { + break; } } - }) + })) .expect("spawn watcher") } |
