Module ring_buffer

Module ring_buffer 

Source
Expand description

Ring buffer implementations for streaming data processing

This module provides two distinct ring buffer implementations:

  • LocalRingBuffer: Single-threaded only, no synchronization, maximum performance
  • RingBuffer: Thread-safe with Arc<RwLock> synchronization, safe for concurrent access

§Performance Characteristics

Both implementations provide:

  • O(1) push and pop operations
  • O(k) sliding window operations (k = window size)
  • Bounded capacity with automatic overwrite of oldest elements
  • Direct indexed access for efficient windowing

LocalRingBuffer advantages:

  • No synchronization overhead
  • ~2x faster than thread-safe variant
  • Optimal for single-threaded streaming algorithms

RingBuffer advantages:

  • Thread-safe with multiple readers/writers
  • Suitable for concurrent streaming pipelines

Structs§

LocalRingBuffer
Single-threaded ring buffer optimized for maximum performance
RingBuffer
Thread-safe ring buffer for streaming data