pub struct FrameLoop { /* private fields */ }Expand description
The fixed-timestep schedule: a passive integer state machine.
It never reads a clock — it cannot, having no dependency that offers
one — so a run is reproducible exactly to the extent that the sequence
of timestamps handed to FrameLoop::begin_frame is.
Implementations§
Source§impl FrameLoop
impl FrameLoop
Sourcepub const fn new(
timestep: Timestep,
budget: StepBudget,
start: Timestamp,
) -> Self
pub const fn new( timestep: Timestep, budget: StepBudget, start: Timestamp, ) -> Self
A schedule anchored at start, with an empty bank and tick zero.
Anchor after expensive bring-up (device creation, asset load): time banked before the first frame is time the budget has to refuse, so a schedule anchored too early opens with a clamped burst and a nonzero drop count that means nothing.
Sourcepub fn begin_frame(&mut self, now: Timestamp) -> FramePlan
pub fn begin_frame(&mut self, now: Timestamp) -> FramePlan
Advance the schedule to now and report what this frame must do.
A pure state transition: a function of the timestep, the budget,
prior state, and now — nothing else. It cannot fail, so it
returns no Result; an uninhabitable error variant would be a lie
about the API. No clock is read here or anywhere in this crate.
Sourcepub fn resync(&mut self, now: Timestamp)
pub fn resync(&mut self, now: Timestamp)
Discard the gap since the last frame, keeping the sub-timestep remainder and the tick count.
For pauses the caller knows about — a finished load, a resumed dormant window, a breakpoint. Never automatic: a “delta over threshold implies resync” heuristic would hide exactly the stall the step budget exists to expose.
Sourcepub const fn simulated(&self) -> Nanos
pub const fn simulated(&self) -> Nanos
The simulation’s own clock: tick × timestep, saturating. Exact by
construction, and therefore never the measured wall time.
Sourcepub const fn remainder(&self) -> Nanos
pub const fn remainder(&self) -> Nanos
Elapsed time banked but not yet consumed by a step; below
FrameLoop::timestep once a frame has been planned.