From ef4ec226ef720f4c3bdba5ae534465f67cda04ee Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 23:38:22 +0100 Subject: remake worker wakes up when vote is due --- src/remake/local.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/remake/local.rs') diff --git a/src/remake/local.rs b/src/remake/local.rs index 60f7184..7810690 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -188,6 +188,14 @@ impl RemakeState { self.lock().coordinating.contains(id) } + /// How long until the vote `vote_due` scheduled is due, while it is ahead: the + /// worker wakes up for it (`switch`). + pub(crate) fn vote_wait(&self, now: UnixMillis) -> Option { + let (_, due) = self.lock().vote_due.clone()?; + // A millisecond late rather than early: early, it would find nothing due. + (due > now).then(|| Duration::from_millis(due.0 - now.0 + 1)) + } + /// When this node votes for `remake` (`vote::cast`): asked first, `now` plus /// `delay()`; asked again, the same time. pub(crate) fn vote_due( -- cgit v1.3.1