pub struct BoundedPool<T> { /* private fields */ }Expand description
Fixed-capacity object pool with LIFO reuse.
All objects are pre-initialized at construction. When all objects are
acquired, try_acquire() returns None.
§Example
use nexus_pool::local::BoundedPool;
let pool = BoundedPool::new(
100,
|| Vec::<u8>::with_capacity(1024),
|v| v.clear(),
);
let mut buf = pool.try_acquire().unwrap();
buf.extend_from_slice(b"hello");
// buf auto-returns to pool on drop, clear() is calledImplementations§
Source§impl<T> BoundedPool<T>
impl<T> BoundedPool<T>
Auto Trait Implementations§
impl<T> Freeze for BoundedPool<T>
impl<T> !RefUnwindSafe for BoundedPool<T>
impl<T> !Send for BoundedPool<T>
impl<T> !Sync for BoundedPool<T>
impl<T> Unpin for BoundedPool<T>
impl<T> !UnwindSafe for BoundedPool<T>
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