struct NodePool {
head: AtomicU64,
}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.
Lock-free LIFO pool of reusable MailboxMessage nodes.
Used by IntrusiveMailbox to avoid heap allocation in IRQ context.
Nodes are recycled: after pop(), the node is returned to the pool
instead of freed; on push(), the pool is checked first before
allocating a fresh node.
ABA protection: the head pointer is tagged with a monotonic generation counter to prevent the ABA problem on concurrent pop/push cycles.
Fields§
§head: AtomicU64Implementations§
Source§impl NodePool
impl NodePool
const fn new() -> Self
Sourcefn preallocate(&self, count: usize)
fn preallocate(&self, count: usize)
Pre-allocate count nodes into the pool.
Sourcefn try_pop_raw(&self) -> Option<*mut MailboxMessage>
fn try_pop_raw(&self) -> Option<*mut MailboxMessage>
Try to pop a node from the pool (lock-free, ABA-safe).
Sourcefn push_raw(&self, ptr: *mut MailboxMessage)
fn push_raw(&self, ptr: *mut MailboxMessage)
Push a raw node pointer back into the pool (lock-free, ABA-safe).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NodePool
impl RefUnwindSafe for NodePool
impl Send for NodePool
impl Sync for NodePool
impl Unpin for NodePool
impl UnsafeUnpin for NodePool
impl UnwindSafe for NodePool
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