pub struct OptimizedRingBuffer<const N: usize = 64> { /* private fields */ }Expand description
Optimized lock-free ring buffer with power-of-2 size.
Uses atomic operations for thread-safe enqueue/dequeue. Power-of-2 size enables fast modulo via bitwise AND.
Implementations§
Source§impl<const N: usize> OptimizedRingBuffer<N>
impl<const N: usize> OptimizedRingBuffer<N>
Sourcepub fn new(region: RegionHandle) -> Self
pub fn new(region: RegionHandle) -> Self
Sourcepub fn region(&self) -> RegionHandle
pub fn region(&self) -> RegionHandle
Returns the region handle.
Sourcepub fn peek(&self) -> Option<&OptimizedRingEntry>
pub fn peek(&self) -> Option<&OptimizedRingEntry>
Peeks at the next entry without removing it.
Sourcepub fn try_enqueue(&mut self, data: &[u8], priority: MsgPriority) -> Result<()>
pub fn try_enqueue(&mut self, data: &[u8], priority: MsgPriority) -> Result<()>
Tries to enqueue without blocking, returns immediately.
Sourcepub fn try_dequeue(
&mut self,
buf: &mut [u8],
) -> Result<(OptimizedRingEntry, usize)>
pub fn try_dequeue( &mut self, buf: &mut [u8], ) -> Result<(OptimizedRingEntry, usize)>
Tries to dequeue without blocking, returns immediately.
Trait Implementations§
Source§impl<const N: usize> Default for OptimizedRingBuffer<N>
impl<const N: usize> Default for OptimizedRingBuffer<N>
impl<const N: usize> Send for OptimizedRingBuffer<N>
impl<const N: usize> Sync for OptimizedRingBuffer<N>
Auto Trait Implementations§
impl<const N: usize = 64> !Freeze for OptimizedRingBuffer<N>
impl<const N: usize> RefUnwindSafe for OptimizedRingBuffer<N>
impl<const N: usize> Unpin for OptimizedRingBuffer<N>
impl<const N: usize> UnsafeUnpin for OptimizedRingBuffer<N>
impl<const N: usize> UnwindSafe for OptimizedRingBuffer<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more