Skip to main content

IntrusiveMailbox

Struct IntrusiveMailbox 

Source
pub struct IntrusiveMailbox {
    head: AtomicUsize,
}
Expand description

A lock-free LIFO mailbox (stack) for kernel-internal IPC.

Messages are pushed atomically to the head of an intrusive linked list and popped from the head. This is not a FIFO queue : message order is reversed on reception.

§Use case

Use for notification-style IPC between trusted kernel components where low latency (~10 cycles) matters more than message ordering. For FIFO-guaranteed IPC, use LockFreeRing.

Fields§

§head: AtomicUsize

Implementations§

Source§

impl IntrusiveMailbox

Source

pub const fn new() -> Self

Create a new empty mailbox.

Source

pub fn push(&self, msg: &[u8]) -> Result<(), MailboxError>

Push a message onto the mailbox (LIFO : inserted at head).

Allocates a new MailboxMessage from the kernel heap. This allocation is the primary cost; for a deterministic fast path consider a pre-allocated freelist (see design doc §12.15).

Source

pub fn pop(&self) -> Option<Box<MailboxMessage>>

Pop a message from the mailbox (LIFO : from head).

Source

pub fn is_empty(&self) -> bool

Whether the mailbox is empty.

Trait Implementations§

Source§

impl Debug for IntrusiveMailbox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IpcConsumer for IntrusiveMailbox

Source§

fn recv(&self, buf: &mut [u8]) -> Result<usize, IpcError>

Receive a message, blocking if the buffer is empty.
Source§

fn try_recv(&self, buf: &mut [u8]) -> Result<Option<usize>, IpcError>

Receive without blocking.
Source§

impl IpcProducer for IntrusiveMailbox

Source§

fn send(&self, msg: &[u8]) -> Result<(), IpcError>

Send a message, blocking if the buffer is full.
Source§

fn try_send(&self, msg: &[u8]) -> Result<(), IpcError>

Send without blocking.
Source§

impl IpcTransport for IntrusiveMailbox

Source§

fn level(&self) -> TransportLevel

The isolation level of this transport.
Source§

fn capabilities(&self) -> TransportCapabilities

Static capabilities of this transport.
Source§

fn name(&self) -> &'static str

Human-readable name for debugging / profiling.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.