Skip to main content

Module seq_ring

Module seq_ring 

Source
Expand description

Lock-free SPSC overwrite ring for high-rate telemetry in no-std contexts.

§Overview

  • Single producer, single consumer.
  • Producer never blocks; new writes overwrite the oldest slots when the ring wraps.
  • Sequence numbers are monotonically increasing u32; 0 is reserved to mean “empty”.
  • The consumer can drain in-order (poll_one/poll_up_to) or sample the newest value (latest).
  • If the consumer lags by more than N, it skips ahead and reports the number of dropped items.

§Memory ordering

The producer writes the value, publishes the per-slot sequence, then publishes the newest sequence. The consumer validates the per-slot sequence before and after reading, which avoids torn reads when the producer overwrites a slot.

§Notes

  • T is Copy to allow returning values by copy without allocation.
  • The &T passed to hooks is a reference to a local copy made during the read.

Structs§

Consumer
Consumer handle for reading from the ring.
PollStats
Producer
Producer handle for writing into the ring.
SeqRing
Overwrite ring for SPSC high-rate telemetry. Producer never waits; consumer may drop if it lags > N.