Skip to main content

IntrusiveMailbox

Struct IntrusiveMailbox 

Source
pub struct IntrusiveMailbox {
    head: AtomicUsize,
    pool: NodePool,
}

Fields§

§head: AtomicUsize§pool: NodePool

Pool of pre-allocated nodes for IRQ-safe push/pop without heap alloc.

Implementations§

Source§

impl IntrusiveMailbox

Source

pub fn new() -> Self

Create a new empty mailbox with FREELIST_CAPACITY pre-allocated nodes.

Source

pub const fn new_empty() -> Self

Create a new empty mailbox without pre-allocation. Only for const contexts (e.g., static initialisers); the caller must call preallocate_nodes() at runtime before use in IRQ context.

Source

pub fn preallocate_nodes(&self, count: usize)

Pre-allocate additional nodes at runtime.

Source

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

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

Tries the pre-allocated node pool first. Falls back to heap allocation only if the pool is empty. In IRQ context the pool should never be empty if FREELIST_CAPACITY is large enough.

Source

pub fn pop(&self) -> Option<IpcMessage>

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

Copies the message data out of the intrusive node, then returns the node to the pre-allocated pool. The caller receives an owned IpcMessage value : no pointers into recycled memory.

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§

fn send_vectored(&self, bufs: &[&[u8]]) -> Result<(), IpcError>

Send using vectored I/O (scatter-gather). Read more
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.