pub struct LockFreeRing {
queue: ArrayQueue<Box<[u8]>>,
slot_limit: usize,
frames: Vec<PhysFrame>,
}Expand description
A bounded lock-free message queue.
Internally uses [crossbeam_queue::ArrayQueue<Box<[u8]>>] for safe,
tested message passing. Also allocates minimal physical frames for
frame_phys_addrs() used by the shared-ring IPC syscall.
Fields§
§queue: ArrayQueue<Box<[u8]>>§slot_limit: usize§frames: Vec<PhysFrame>Implementations§
Source§impl LockFreeRing
impl LockFreeRing
Sourceconst DEFAULT_CAPACITY: u32 = 256
const DEFAULT_CAPACITY: u32 = 256
Default slot count.
Sourcepub fn new(slot_count: u32, slot_size: usize) -> Result<Arc<Self>, RingError>
pub fn new(slot_count: u32, slot_size: usize) -> Result<Arc<Self>, RingError>
Create a new ring with slot_count slots for messages up to
slot_size bytes.
Sourcepub fn frame_phys_addrs(&self) -> Vec<u64>
pub fn frame_phys_addrs(&self) -> Vec<u64>
Physical addresses of the backing frames (for IPC ring compat).
Sourcepub fn write(&self, data: &[u8]) -> Result<(), RingError>
pub fn write(&self, data: &[u8]) -> Result<(), RingError>
Write data into the ring. Returns Full if no slot is available,
or MessageTooLarge if the data exceeds the slot capacity.
Sourcepub fn read(&self, buf: &mut [u8]) -> Result<usize, RingError>
pub fn read(&self, buf: &mut [u8]) -> Result<usize, RingError>
Read one message from the ring into buf.
Sourcepub fn write_vectored(&self, bufs: &[&[u8]]) -> Result<(), RingError>
pub fn write_vectored(&self, bufs: &[&[u8]]) -> Result<(), RingError>
Write multiple buffers in a single slot (scatter-gather).
Sourcepub fn try_read(&self, buf: &mut [u8]) -> Result<Option<usize>, RingError>
pub fn try_read(&self, buf: &mut [u8]) -> Result<Option<usize>, RingError>
Non-blocking read. Returns Ok(None) when the ring is empty.
Sourcepub fn notify_consumer_raw(&self)
pub fn notify_consumer_raw(&self)
Notify the consumer that new data is available. No-op under ArrayQueue (notification is handled by the caller).
Sourcepub fn notify_producer_raw(&self)
pub fn notify_producer_raw(&self)
Notify the producer that space has been freed. No-op under ArrayQueue.
Sourcepub fn dma_buffer(&self, _slot_index: u32) -> Option<DmaBuffer>
pub fn dma_buffer(&self, _slot_index: u32) -> Option<DmaBuffer>
DMA buffer descriptor.
ArrayQueue does not expose physical addresses; this method returns
None. The NIC data plane uses dedicated hardware ring buffers.
Trait Implementations§
Source§impl Debug for LockFreeRing
impl Debug for LockFreeRing
Source§impl Drop for LockFreeRing
impl Drop for LockFreeRing
Source§impl IpcConsumer for LockFreeRing
impl IpcConsumer for LockFreeRing
Source§impl IpcNotification for LockFreeRing
impl IpcNotification for LockFreeRing
Source§fn notify_consumer(&self)
fn notify_consumer(&self)
Source§fn notify_producer(&self)
fn notify_producer(&self)
Source§impl IpcProducer for LockFreeRing
impl IpcProducer for LockFreeRing
Source§impl IpcTransport for LockFreeRing
impl IpcTransport for LockFreeRing
Source§fn level(&self) -> TransportLevel
fn level(&self) -> TransportLevel
Source§fn capabilities(&self) -> TransportCapabilities
fn capabilities(&self) -> TransportCapabilities
impl Send for LockFreeRing
impl Sync for LockFreeRing
Auto Trait Implementations§
impl !Freeze for LockFreeRing
impl RefUnwindSafe for LockFreeRing
impl Unpin for LockFreeRing
impl UnsafeUnpin for LockFreeRing
impl UnwindSafe for LockFreeRing
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more