pub struct Ticks(/* private fields */);Expand description
A hardware counter reading: whatever a monotonic tick source produced, at that source’s own frequency.
Ticks, not nanoseconds. Deriving nanoseconds costs a multiply and a
divide per read — see crate::anchor::ToUnixNanos for where that
conversion belongs (the edge, once per anchor/export), never on the hot
path where a caller just wants now_ticks - then_ticks. A counter’s
rate is whatever the hardware runs at: 24 MHz for the ARM generic timer
(CNTVCT_EL0), ~1 GHz nominal for RDTSC, 100 MHz for a PTP hardware
clock, 1000 Hz for prime’s timer wheel (see
prime::core::timer::Clock, the sibling tick source this type is
deliberately compatible with).
#[repr(transparent)] over u64, matching
proxima_protocols::Instant/Duration’s convention for tier-3 value
types.
Implementations§
Source§impl Ticks
impl Ticks
Sourcepub const fn from_raw(raw: u64) -> Self
pub const fn from_raw(raw: u64) -> Self
Construct from a raw tick count. Hardware source impls use this; the value’s meaning (which counter, which frequency) travels separately, alongside the source that produced it.
Sourcepub const fn wrapping_sub(self, earlier: Self) -> u64
pub const fn wrapping_sub(self, earlier: Self) -> u64
self - earlier, wrapping on counter rollover (a free-running
hardware counter wraps at u64::MAX; the elapsed count is still
correct via modular arithmetic as long as fewer than u64::MAX
ticks elapsed between the two reads, true for any counter this
side of the heat death of the universe).