Skip to main content

CycleGuard

Struct CycleGuard 

Source
pub struct CycleGuard { /* private fields */ }
Expand description

A windowed cycle detector over a stream of u64 fingerprints.

Implementations§

Source§

impl CycleGuard

Source

pub fn new() -> Self

Source

pub fn reset(&mut self)

Drop all recorded history (call at the start of each conversion).

Source

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.

Source

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.

Source

pub fn backlog_trace(&self) -> Vec<usize>

The backlog samples, oldest first (for the LATEXML_DEBUG_FATAL trace).

Trait Implementations§

Source§

impl Debug for CycleGuard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CycleGuard

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.