pub struct SnapshotRing { /* private fields */ }Expand description
A bounded ring of ArenaSnapshots: “current” (the most recently
pushed entry, ring index 0) plus up to depth older entries. Never
retains more than depth + 1 entries, no matter how many times
Self::push is called – the “a design with no $past retention need
pays no retention cost beyond entry 0” guard (see
snapshot_ring_depth_0_design_allocates_no_ring below). Whether a ring
is allocated at all for a given instance is a decision this type does
not make – sched::control::Engine only ever constructs one when the
design has at least one assertion/clocking-block/$past site to begin
with (§1.4’s “not every instance, to avoid taxing designs with no SVA at
all”); a design with none never calls Self::new and pays nothing.
Implementations§
Source§impl SnapshotRing
impl SnapshotRing
Sourcepub fn new(depth: usize) -> Self
pub fn new(depth: usize) -> Self
depth = N (16.9.3/16.9.4’s largest literal number_of_ticks
argument across the whole design that needs this ring; 0 if
$past/$past_gclk is never called with a nonzero tick count for
it). Allocates nothing up front (VecDeque::new(), never
with_capacity) – the first Self::push call is this ring’s
first real allocation.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
N as passed to Self::new – how many entries beyond “current”
this ring retains.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many entries are currently retained (<= depth + 1) – a test/
diagnostic accessor; Self::push/Self::get already enforce the
bound internally without consulting this.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true before the first Self::push (clippy’s len_without_is_empty).
Sourcepub fn push(&mut self, snap: ArenaSnapshot)
pub fn push(&mut self, snap: ArenaSnapshot)
Appends snap as the new “current” entry, evicting the oldest entry
once the ring already holds depth + 1 entries – never grows past
that bound no matter how many times this is called.
Sourcepub fn get(&self, ticks_back: usize) -> Option<&ArenaSnapshot>
pub fn get(&self, ticks_back: usize) -> Option<&ArenaSnapshot>
The entry ticks_back pushes before the most recent one (0 =
“current”, the value Self::push most recently stored). None
when ticks_back exceeds how many entries are actually retained –
either because the ring hasn’t been pushed to that many times yet
(simulation start; 16.9.3’s own “before the Nth previous clock tick,
treat the value as X” case, left to the $past lowering task to
turn into the right X-valued result) or because ticks_back > depth (a caller bug this primitive reports rather than panics on –
unlike RegionQueues’s “this region can never be serviced at all”
structural impossibility, this is a plain out-of-range read).