From 768da4fd62b390014fcaf55e23dbb45ca61ad79b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 19:50:24 +0000 Subject: 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. --- src/watch/scheduler.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/watch/scheduler.rs') 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, db: Db, stop: Arc) -> 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") } -- cgit v1.2.3