pub struct HeapBufferPool(/* private fields */);Expand description
A bounded, shareable collection of stable initialized slots in one contiguous slab. Construction reserves all payload storage; acquiring, freezing, slicing, and returning leases allocate no payload or reference-count wrappers.
Pools may be shared across connections and file pipelines. Exhaustion waits with cancellation instead of growing the pool. Retained views count against capacity. This portable implementation of BufferPool uses a heap allocation. Backends may supply another pool implementation with the same ownership contract.
Implementations§
Source§impl HeapBufferPool
impl HeapBufferPool
pub fn new(buffers: usize, buffer_size: usize) -> Result<Self>
Sourcepub fn with_options(options: BufferPoolOptions) -> Result<Self>
pub fn with_options(options: BufferPoolOptions) -> Result<Self>
Reserve one contiguous initialized allocation. Slot starts satisfy the requested alignment; padding is outside the usable payload budget.
pub fn capacity(&self) -> usize
pub fn buffer_size(&self) -> usize
pub fn alignment(&self) -> usize
Sourcepub fn try_acquire(&self) -> Option<BufferLease>
pub fn try_acquire(&self) -> Option<BufferLease>
Acquire exclusive writable storage immediately, or return None without allocating.
Sourcepub async fn acquire(
&self,
cancellation: &Cancellation,
) -> Result<BufferLease, Cancelled>
pub async fn acquire( &self, cancellation: &Cancellation, ) -> Result<BufferLease, Cancelled>
Wait for one lease. Pre-cancellation leaves capacity unchanged; a successfully acquired lease wins a later cancellation race.
Trait Implementations§
Source§impl BufferPool for HeapBufferPool
impl BufferPool for HeapBufferPool
type Buffer = BufferLease
Source§fn capacity(&self) -> usize
fn capacity(&self) -> usize
fn buffer_size(&self) -> usize
fn alignment(&self) -> usize
Source§fn try_acquire(&self) -> Option<Self::Buffer>
fn try_acquire(&self) -> Option<Self::Buffer>
None without waiting for capacity.