Skip to main content

HeapBufferPool

Struct HeapBufferPool 

Source
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

Source

pub fn new(buffers: usize, buffer_size: usize) -> Result<Self>

Source

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.

Source

pub fn capacity(&self) -> usize

Source

pub fn buffer_size(&self) -> usize

Source

pub fn alignment(&self) -> usize

Source

pub fn try_acquire(&self) -> Option<BufferLease>

Acquire exclusive writable storage immediately, or return None without allocating.

Source

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

Source§

type Buffer = BufferLease

Source§

fn capacity(&self) -> usize

Total slot capacity, including leased and published buffers, rather than the number currently free. Worker-local caches are part of this total.
Source§

fn buffer_size(&self) -> usize

Source§

fn alignment(&self) -> usize

Source§

fn try_acquire(&self) -> Option<Self::Buffer>

Acquire immediately, or return None without waiting for capacity.
Source§

async fn acquire( &self, cancellation: &Cancellation, ) -> Result<Self::Buffer, Cancelled>

Pre-cancellation leaves capacity unchanged. Acquisition wins a subsequent cancellation race. Dropping or forgetting a pending acquisition must not release storage still accessible by another owner.
Source§

impl Clone for HeapBufferPool

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.