Skip to main content

BufferPool

Trait BufferPool 

Source
pub trait BufferPool:
    Clone
    + Send
    + Sync
    + 'static {
    type Buffer: ReceiveBuffer;

    // Required methods
    fn capacity(&self) -> usize;
    fn buffer_size(&self) -> usize;
    fn alignment(&self) -> usize;
    fn try_acquire(&self) -> Option<Self::Buffer>;
    fn acquire(
        &self,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<Self::Buffer, Cancelled>> + Send;
}
Expand description

A bounded, shareable source of exclusively writable, stable receive storage. Clones share the same capacity. Completed buffers and their frozen views retain storage independently of pool handles, receivers, and polling threads; the final owner makes that slot reusable.

Published receive buffers count against capacity, including while an accepted receive is idle. Use a separate pool for independently required scratch buffers or file pipelines. The scheduler’s portable factory supplies a shared total budget; concrete backend experiments may document a different capacity distribution.

Acquisition returns a fully initialized buffer_size() prefix with at least alignment() alignment. Its previous contents are unspecified. Exhaustion waits with cancellation instead of growing the pool. Retained views and accepted I/O count against capacity until their access retires, including after future abandonment. Kernel registration and publication are implementation details; neither may grant concurrent access to a leased buffer.

Required Associated Types§

Required Methods§

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

fn acquire( &self, cancellation: &Cancellation, ) -> impl Future<Output = Result<Self::Buffer, Cancelled>> + Send

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§