Skip to main content

Crate photon_ring

Crate photon_ring 

Source
Expand description

§Photon Ring

Ultra-low-latency SPMC pub/sub using seqlock-stamped ring buffers.

no_std compatible (requires alloc). Core channel, bus, and wait strategies work without the standard library. The topology module requires OS threads and is available on supported platforms only.

§Key design

  • Seqlock per slot — stamp and payload share a cache line; readers never take a lock, writers never allocate.
  • T: Copy — enables safe memcpy reads; torn reads are detected and retried (no Drop / double-free concerns).
  • Per-consumer cursor — zero contention between subscribers.
  • Single-producer — no write-side synchronisation; the seqlock invariant is upheld by &mut self on Publisher::publish.

§Quick start

// Low-level SPMC channel
let (mut pub_, subs) = photon_ring::channel::<u64>(64);
let mut sub = subs.subscribe();
pub_.publish(42);
assert_eq!(sub.try_recv(), Ok(42));

// Named-topic bus
let bus = photon_ring::Photon::<u64>::new(64);
let mut p = bus.publisher("topic-a");
let mut s = bus.subscribe("topic-a");
p.publish(7);
assert_eq!(s.try_recv(), Ok(7));

Re-exports§

pub use channel::channel;
pub use channel::channel_bounded;
pub use channel::channel_mpmc;
pub use channel::Drain;
pub use channel::MpPublisher;
pub use channel::PublishError;
pub use channel::Publisher;
pub use channel::Subscribable;
pub use channel::Subscriber;
pub use channel::SubscriberGroup;
pub use channel::TryRecvError;
pub use wait::WaitStrategy;

Modules§

affinity
CPU core affinity helpers for deterministic cross-core latency.
channel
mem
Platform-specific memory control for ring buffer allocation.
topology
Builder-pattern topology for multi-stage processing pipelines.
wait
Wait strategies for blocking receive operations.

Structs§

Photon
Named-topic pub/sub bus.
Shutdown
A shared shutdown signal for coordinating graceful termination.
TypedBus
A topic bus that supports different message types per topic.