Skip to main content

due

Function due 

Source
pub fn due<'a>(jobs: &'a [Job], state: &mut State, now_ms: i64) -> Vec<&'a Job>
Expand description

The jobs that should run now.

A job that has never run is due immediately when its schedule is an interval — the timer was just installed, and waiting half an hour to prove it works is not useful — and at its next named moment otherwise, so that installing a timer at noon does not execute a 07:30 briefing on the spot.

That second case needs an anchor, and asking every caller to remember seed_first_seen is how a daily job came to never fire at all (#561). So the first sighting is seeded here: a job this tick has no history for is anchored at this tick, due still answers “not yet”, and the next tick has something to measure from. The state is &mut for that reason alone.