Skip to main content

Crate ph_eventing

Crate ph_eventing 

Source
Expand description

Eventing primitives for no-std embedded targets.

§Highlights

  • Lock-free SPSC sequence ring for high-throughput telemetry.
  • No allocation, no dynamic dispatch.
  • Designed for fast producers and potentially slower consumers.

§Quick start

use ph_eventing::SeqRing;

let ring = SeqRing::<u32, 64>::new();
let producer = ring.producer();
let mut consumer = ring.consumer();

producer.push(42);
consumer.poll_one(|seq, v| {
    assert_eq!(seq, 1);
    assert_eq!(*v, 42);
});

§No-std

The crate is #![no_std] by default. Tests require std.

§Targets without atomics

For targets that lack 32-bit atomics (for example thumbv6m-none-eabi), enable portable-atomic-unsafe-assume-single-core or portable-atomic-critical-section.

§Safety and concurrency

This crate is SPSC by design: exactly one producer and one consumer must be active. producer()/consumer() will panic if called while another handle of the same kind is active. Using unsafe to bypass these constraints (or sharing handles concurrently) is undefined behavior.

§Semantics

  • Sequence numbers are monotonically increasing u32 values; 0 is reserved for “empty”.
  • poll_one/poll_up_to drain in-order and return PollStats.
  • latest reads the newest value without advancing the consumer cursor.
  • If the consumer lags by more than N, it skips ahead and reports drops via PollStats.

Re-exports§

pub use seq_ring::Consumer;
pub use seq_ring::PollStats;
pub use seq_ring::Producer;
pub use seq_ring::SeqRing;

Modules§

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