Skip to main content

Module multicast

Module multicast 

Source
Expand description

Zero-copy multicast buffer for shared intermediate stages.

MulticastBuffer<T> implements a pre-allocated ring buffer with per-slot reference counting for single-producer, multiple-consumer (SPMC) multicast. Designed for Ring 0 hot path: zero allocations after construction.

§Design

  • Pre-allocated slots with power-of-2 capacity and bitmask indexing
  • Single writer via publish(), multiple readers via consume()
  • Per-slot atomic refcount tracks outstanding consumers
  • Backpressure: publish() fails when slowest consumer hasn’t freed a slot

§Safety

The single-writer invariant is upheld by the DAG executor, which ensures exactly one thread calls publish() on any given buffer. Multiple threads may call consume() with distinct consumer_idx values.

Structs§

MulticastBuffer
Pre-allocated SPMC multicast buffer with reference-counted slots.