pub struct StatsLedger { /* private fields */ }Expand description
The shared traffic ledger.
Lock-free and const-constructible, so a board declares one static
and hands out &'static references to every producer and reader.
Ordering is Relaxed throughout: each counter is independent, no
reader is deciding anything from the ordering between two of them,
and the alternative buys a fence on the radio’s hot path to make
diagnostics agree about an instant nobody is looking at.
Implementations§
Source§impl StatsLedger
impl StatsLedger
pub const fn new() -> Self
Sourcepub fn add(&self, counter: Counter, n: u32)
pub fn add(&self, counter: Counter, n: u32)
Record n events. Adding zero is free and is the ordinary case
for a mirroring producer whose source has not moved.
Sourcepub fn get(&self, counter: Counter) -> u32
pub fn get(&self, counter: Counter) -> u32
What a host reads: events since boot, or since it last cleared this counter.
Sourcepub fn raw(&self, counter: Counter) -> u32
pub fn raw(&self, counter: Counter) -> u32
The underlying tally, ignoring any clear. Nothing on the wire reports this; it is here so a device that wants a since-boot view of its own has one.
Sourcepub fn reset(&self, counter: Counter)
pub fn reset(&self, counter: Counter)
Start this counter over from here.
Clearing several counters is several of these, so a frame landing mid-sweep is counted before one and after another. Nothing reads them closely enough for that to matter, and the alternative is a lock on the radio’s hot path.