pub struct Pool<T: PooledObject> { /* private fields */ }Expand description
A pool of some objects of type T.
Implementations§
Source§impl<T: PooledObject> Pool<T>
impl<T: PooledObject> Pool<T>
Sourcepub fn new(cap: usize) -> Self
pub fn new(cap: usize) -> Self
Returns a new pool with a maximum capacity of cap.
This capacity is fixed over the lifetime of the pool.
Sourcepub fn take(&self, clear: impl FnOnce(&mut T), new: impl FnOnce() -> T) -> T
pub fn take(&self, clear: impl FnOnce(&mut T), new: impl FnOnce() -> T) -> T
Takes an object from the pool or creates a new one.
Sourcepub fn dropped_count(&self) -> usize
pub fn dropped_count(&self) -> usize
Returns the number of pages dropped by the pool because the pool was at capacity.
Sourcepub fn new_allocated_count(&self) -> usize
pub fn new_allocated_count(&self) -> usize
Returns the number of fresh objects allocated through the pool.
Sourcepub fn reused_count(&self) -> usize
pub fn reused_count(&self) -> usize
Returns the number of objects reused from the pool.
Sourcepub fn returned_count(&self) -> usize
pub fn returned_count(&self) -> usize
Returns the number of objects returned to the pool.
Trait Implementations§
Source§impl<T: PooledObject> Clone for Pool<T>
impl<T: PooledObject> Clone for Pool<T>
Auto Trait Implementations§
impl<T> Freeze for Pool<T>
impl<T> RefUnwindSafe for Pool<T>
impl<T> Send for Pool<T>where
T: Send,
impl<T> Sync for Pool<T>where
T: Send,
impl<T> Unpin for Pool<T>
impl<T> UnwindSafe for Pool<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more