Skip to main content

Module buffer_pool

Module buffer_pool 

Source
Expand description

Fixed-capacity pool of &'static mut [u8] receive/scratch buffers. Pure no_std (uses only core::). Exposed without a feature gate so both the bare-metal and std/tokio paths can reach buffer_pool::BufferPool and buffer_pool::BufferLease. Fixed-capacity pool of byte buffers with claim/release semantics, mirroring the channel pools in this module. A BufferPool is declared as a static (bare-metal) or held behind an Arc (std/tokio) by the consumer; each claim hands out one slot as a BufferLease (a raw NonNull slice whose exclusivity is enforced by the per-slot AtomicBool, not the borrow checker) that returns the slot on drop.

Synchronization uses per-slot AtomicBool compare-exchange so the same code is valid on the bare-metal target and on std without requiring a critical-section implementation.

Structsยง

BufferLease
RAII handle to one claimed buffer from a BufferPool.
BufferPool
Fixed-capacity pool of LEN-byte buffers. Declare as a static and call Self::claim to obtain a BufferLease.