Skip to main content

Module ring_buffer

Module ring_buffer 

Source
Expand description

Lock-free ring buffer for streaming channels.

This module provides a heap-allocated ring buffer optimized for single-producer single-consumer (SPSC) scenarios with support for MPSC mode via atomic slot claiming.

§Design

  • Heap-allocated with runtime capacity (unlike const-generic alloc::RingBuffer)
  • Power-of-2 capacity with bitmask indexing for fast modulo
  • Cache-padded head/tail indices prevent false sharing
  • Acquire/Release memory ordering for lock-free operation
  • Separate claim_counter for MPSC slot claiming

§Performance

Target: < 20ns per push/pop operation in SPSC mode.

Structs§

RingBuffer
A lock-free ring buffer with runtime-specified capacity.