pub struct TickBatch { /* private fields */ }Expand description
An allocation-free snapshot of a frame budget and its scheduled tick IDs.
Created by FixedClock::advance_batch, session::GameSession::advance_batch
or session::GameSession::step_paused_batch. Scheduling already advanced the
clock by the whole budget. Iterating, skipping, copying or dropping this value
never advances or rolls back that clock and does not record actual execution.
Track executed updates in your runner; an iterator yield alone is not an update.
A snapshot keeps its original IDs even after the clock advances or resets.
Discard pending batches when resetting your simulation, since reset reuses IDs.
See Self::ticks for an example of abandoning a batch early.
Implementations§
Source§impl TickBatch
impl TickBatch
Sourcepub fn frame(self) -> FrameStep
pub fn frame(self) -> FrameStep
The unchanged timing budget, including zero-work and paused-step alpha.
use ferravex_core::FixedClock;
let batch = FixedClock::new(64.0, 2).advance_batch(3.5 / 64.0);
assert_eq!(batch.frame().steps, 2);
assert_eq!(batch.frame().alpha, 0.5);
assert_eq!(batch.frame().dropped_seconds, 1.0 / 64.0);Sourcepub fn ticks(
self,
) -> impl ExactSizeIterator<Item = TickContext> + DoubleEndedIterator + FusedIterator
pub fn ticks( self, ) -> impl ExactSizeIterator<Item = TickContext> + DoubleEndedIterator + FusedIterator
Iterate scheduled contexts without allocation or borrowing the clock.
Each ID is tick_before.wrapping_add(batch_index + 1). Discarded catch-up
time consumes no IDs. Empty budgets yield nothing. Every call produces the
same contexts, so executing a batch twice would repeat work with the same IDs.
Reverse/skip iteration preserves indices from the original forward order.
nth/nth_back skip in constant time, even for a maximum-sized budget.
use ferravex_core::FixedClock;
let mut clock = FixedClock::new(64.0, 8);
let batch = clock.advance_batch(3.0 / 64.0);
let mut executed = 0;
for context in batch.ticks().take(1) {
assert_eq!(context.tick, 1);
assert_eq!(context.batch_index, 0);
assert_eq!(context.dt, 1.0 / 64.0);
executed += 1; // Invoke the simulation here, then stop this batch.
}
assert_eq!(executed, 1);
assert_eq!(clock.tick(), 3); // Includes the two unexecuted scheduled IDs.
assert_eq!(clock.advance_batch(1.0 / 64.0).ticks().next().unwrap().tick, 4);