pub struct CycleGuard { /* private fields */ }Expand description
A windowed cycle detector over a stream of u64 fingerprints.
Implementations§
Source§impl CycleGuard
impl CycleGuard
pub fn new() -> Self
Sourcepub fn push(&mut self, fp: u64, backlog: usize) -> Option<usize>
pub fn push(&mut self, fp: u64, backlog: usize) -> Option<usize>
Record one fingerprint. Returns Some(period) if the recent stream is a
window of period items repeated at least REPEAT times.
backlog is the caller’s pending-input measure at this push — the
gullet passes its pushback length, sampled only at check points. A
detected period is reported only when the backlog did NOT shrink
across the repeated span: a genuine cycle re-expands every period, so
its backlog holds level or grows (\def\x{a\x}, \def\x{\x\x}),
while a periodic stream whose backlog drains is pre-built data being
consumed — \prg_replicate:nn {10000} {<body>} unpacking l3intarray’s
\intarray_gzero:N body into the pushback and then executing it entry
by entry (maze manual, a cycle-guard Fatal on a finite construct).
Callers without a backlog notion (the stomach’s box stream) pass a
constant, which never gates.
Sourcepub fn checked(&self) -> bool
pub fn checked(&self) -> bool
True when the newest Self::push ran the periodicity check, whatever it found: a caller tracking how long a
period holds (Persistence) learns from it that a check saw none.
Sourcepub fn backlog_trace(&self) -> Vec<usize>
pub fn backlog_trace(&self) -> Vec<usize>
The backlog samples, oldest first (for the LATEXML_DEBUG_FATAL trace).