pub struct BufferPool<T> { /* private fields */ }Implementations§
Source§impl<T> BufferPool<T>
impl<T> BufferPool<T>
Sourcepub fn from_buffers(buffers: Vec<T>) -> Self
pub fn from_buffers(buffers: Vec<T>) -> Self
Build a pool from a pre-allocated set of buffers. The number of buffers fixes the pool’s capacity; the pool never grows.
pub fn capacity(&self) -> usize
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
Number of buffers currently checked out (capacity − available).
Sourcepub fn try_acquire(&self) -> Option<PooledBuffer<T>>
pub fn try_acquire(&self) -> Option<PooledBuffer<T>>
Try to acquire one buffer. Returns None if the pool is exhausted.
Sourcepub fn try_acquire_or_err(&self) -> Result<PooledBuffer<T>, G2gError>
pub fn try_acquire_or_err(&self) -> Result<PooledBuffer<T>, G2gError>
Sync convenience: acquire one buffer, or fail with PoolExhausted.
Prefer Self::acquire inside async element loops — it awaits
capacity instead of failing fast.
Sourcepub fn acquire(&self) -> AcquireFuture<'_, T> ⓘ
pub fn acquire(&self) -> AcquireFuture<'_, T> ⓘ
Acquire one buffer, awaiting until one becomes available.
Source§impl BufferPool<Box<[u8]>>
impl BufferPool<Box<[u8]>>
Sourcepub fn new_byte_pool(count: usize, bytes: usize) -> Self
pub fn new_byte_pool(count: usize, bytes: usize) -> Self
Allocate a CPU byte pool of count buffers, each bytes long.
Trait Implementations§
Source§impl<T> Clone for BufferPool<T>
impl<T> Clone for BufferPool<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for BufferPool<T>
impl<T> !UnwindSafe for BufferPool<T>
impl<T> Freeze for BufferPool<T>
impl<T> Send for BufferPool<T>
impl<T> Sync for BufferPool<T>
impl<T> Unpin for BufferPool<T>
impl<T> UnsafeUnpin for BufferPool<T>where
Arc<PoolInner<T>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more