in nfm-controller/src/utils/event_timer.rs [94:112]
fn try_sleep(&mut self, until_us: u64, mut now_us: u64) -> Result<(), String> {
let mut span = Duration::from_micros(until_us - now_us);
debug!("Waiting {span:?} until the next event...");
while until_us > now_us {
let sleep_fragment_us = (until_us - now_us).min(1_000_000);
span = Duration::from_micros(sleep_fragment_us);
self.clock.sleep(span);
now_us += sleep_fragment_us;
if let Some(exit_flag) = &self.exit_flag {
if exit_flag.load(AtomicOrd::Relaxed) {
return Err("should exit".to_string());
}
}
}
Ok(())
}