pub struct BufferPool { /* private fields */ }Expand description
Simple buffer pool that hands out reusable owned buffers.
§Example
use styx_core::prelude::BufferPool;
let pool = BufferPool::with_limits(4, 1 << 20, 8);
let _lease = pool.lease();Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn with_capacity(capacity: usize, chunk_size: usize) -> BufferPool
pub fn with_capacity(capacity: usize, chunk_size: usize) -> BufferPool
Create a pool with capacity preallocated buffers of chunk_size bytes.
Sourcepub fn with_limits(
capacity: usize,
chunk_size: usize,
max_free: usize,
) -> BufferPool
pub fn with_limits( capacity: usize, chunk_size: usize, max_free: usize, ) -> BufferPool
Create a pool with capacity preallocated buffers and a maximum retained free list.
Sourcepub fn lease(&self) -> BufferLease
pub fn lease(&self) -> BufferLease
Acquire a buffer, allocating if the pool is empty.
Sourcepub fn metrics(&self) -> BufferPoolMetrics
pub fn metrics(&self) -> BufferPoolMetrics
Access metrics counters for this pool.
Trait Implementations§
Source§impl Clone for BufferPool
impl Clone for BufferPool
Source§fn clone(&self) -> BufferPool
fn clone(&self) -> BufferPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnwindSafe for BufferPool
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