pub struct BufferPool { /* private fields */ }Implementations§
Source§impl BufferPool
impl BufferPool
pub const DEFAULT_BUFFER_SIZE: usize
pub const DEFAULT_POOL_SIZE: usize = 10
pub fn new(buffer_size: usize, max_pool_size: usize) -> Self
Sourcepub async fn get(&self) -> Vec<u8> ⓘ
pub async fn get(&self) -> Vec<u8> ⓘ
A Vec<u8> with capacity buffer_size (or more). If the pool is empty,
allocates a fresh one.
Sourcepub async fn return_buffer(&self, buf: Vec<u8>)
pub async fn return_buffer(&self, buf: Vec<u8>)
Returns buf to the pool, shrinking it if it has grown past 2x the
configured size. If the pool is full, the buffer is dropped.
Sourcepub async fn prewarm(&self, count: usize)
pub async fn prewarm(&self, count: usize)
Pre-allocates count buffers at startup so the first request does not
pay the allocation cost.
pub fn buffer_size(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferPool
impl !RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin 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