pub struct SharedBoundedBufferPool(/* private fields */);Expand description
A threadsafe pool with a fixed number of Vec<u8> buffers.
Implementations§
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 SharedBoundedPool 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.
May need to wait for a buffer to become available.
§Potential Panics or Deadlocks
If self.pool_size() == 0, then this method will panic or deadlock.
This method may also cause a deadlock if no buffers are currently available, and the
current thread needs to make progress in order to release a buffer.
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§fn clone(&self) -> SharedBoundedBufferPool
fn clone(&self) -> SharedBoundedBufferPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more