pub struct BoundedBufferPool(/* private fields */);Expand description
A pool with a fixed number of Vec<u8> buffers.
Implementations§
Source§impl BoundedBufferPool
impl BoundedBufferPool
Sourcepub fn new(pool_size: usize, max_buffer_capacity: usize) -> Self
pub fn new(pool_size: usize, max_buffer_capacity: usize) -> Self
Create a new BoundedBufferPool which has the indicated, fixed number of Vec<u8> buffers.
Whenever a buffer is returned to the pool, if its capacity is at most max_buffer_capacity,
then Vec::clear is run on it; otherwise, it is replaced with a new empty Vec<u8>.
Sourcepub fn try_get(&self) -> Result<PooledBuffer<Self>, OutOfBuffers>
pub fn try_get(&self) -> Result<PooledBuffer<Self>, OutOfBuffers>
Get a buffer from the pool, if any are available.
Sourcepub fn get(&self) -> PooledBuffer<Self>
pub fn get(&self) -> PooledBuffer<Self>
Get a buffer from the pool.
§Panics
Panics if no buffers are currently available. As BoundedBufferPool is !Send + !Sync, no
buffer could ever become available while in the body of this function.
Sourcepub fn pool_size(&self) -> usize
pub fn pool_size(&self) -> usize
Get the total number of buffers in this pool, whether available or in-use.
Sourcepub fn available_buffers(&self) -> usize
pub fn available_buffers(&self) -> usize
Get the number of buffers in the pool which are not currently being used.
Trait Implementations§
Source§impl Clone for BoundedBufferPool
impl Clone for BoundedBufferPool
Source§fn clone(&self) -> BoundedBufferPool
fn clone(&self) -> BoundedBufferPool
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 moreSource§impl Debug for BoundedBufferPool
impl Debug for BoundedBufferPool
Source§impl<S: Speed> MirroredClone<S> for BoundedBufferPool
Available on crate feature clone-behavior only.
impl<S: Speed> MirroredClone<S> for BoundedBufferPool
Available on crate feature
clone-behavior only.Source§fn mirrored_clone(&self) -> Self
fn mirrored_clone(&self) -> Self
Get a clone that shares all semantically-important mutable state with its source. Read more
Source§fn fast_mirrored_clone(&self) -> Selfwhere
S: FastSpeed,
fn fast_mirrored_clone(&self) -> Selfwhere
S: FastSpeed,
Get a clone that shares all semantically-important mutable state with its source. Read more
Auto Trait Implementations§
impl Freeze for BoundedBufferPool
impl !RefUnwindSafe for BoundedBufferPool
impl !Send for BoundedBufferPool
impl !Sync for BoundedBufferPool
impl Unpin for BoundedBufferPool
impl !UnwindSafe for BoundedBufferPool
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