pub struct TickCell { /* private fields */ }Expand description
A shared, coarsely-updated tick count — the common per-core/per-shard “what time is it, roughly” cell, distinct from a per-read hardware register.
Some deployments do not want every caller reading a hardware counter directly (a syscall-backed clock, a register behind a slow bus, a counter shared across cores where every core hitting the same cache line would thrash it). The usual answer is one owner reads the real source occasionally and writes the result here; every other reader reads this cell instead — cheap, lock-free, and no less accurate than the owner’s update cadence.
TickCell reads exactly like a hardware counter: impl Pipe for &TickCell gives it the same In = (), Out = Ticks, Err = Infallible
source shape as a read_volatile on a memory-mapped register (see
tests/hardware_mmap_seam.rs, which drives both through one
pipeline) — a caller composing a pipeline does not know or care
whether a given tick source is a raw register or this cell.
Deliberately NOT a process-wide static here: how a cell is reached
(a field on a per-core context, threaded through a runtime handle, a
static a caller chooses to declare) is a runtime-wiring decision
this no_std leaf crate does not make on the caller’s behalf.
§Contract
Single writer: TickCell::set is for the one owner that reads the
real source and republishes it. Concurrent set calls from more than
one caller are not synchronized against each other — the underlying
seqlock’s odd/even bump is not itself compare-and-swapped. Any number
of readers may call TickCell::get (or drive it as a Pipe)
concurrently, lock-free.