pub struct Pool<T> { /* private fields */ }Expand description
The pseudo-pool container. This holds the inventory of objects that can be checked in/out & automatically tracks when checked out objects are out of scope to return them to the pool. The objects can carry payloads (which must all be of the same type).
Implementations§
Source§impl<T> Pool<T>
impl<T> Pool<T>
Sourcepub fn new_from_iterable<V: IntoIterator<Item = T>>(vec: V) -> Self
pub fn new_from_iterable<V: IntoIterator<Item = T>>(vec: V) -> Self
Create a new pool with initial contents from an iterable of object payloads.
Sourcepub fn extend_entries<V: IntoIterator<Item = T>>(&mut self, vec: V)
pub fn extend_entries<V: IntoIterator<Item = T>>(&mut self, vec: V)
Add objects to the pool from an iterable of payloads.
Sourcepub fn checkout_blocking(&mut self) -> Result<ExternalPoolEntry<T>>
pub fn checkout_blocking(&mut self) -> Result<ExternalPoolEntry<T>>
Get an object from the pool, if available, or block until an object is available. Returns the object. (This is the entire reason this crate exists.)
Sourcepub fn try_checkout(&mut self) -> Option<ExternalPoolEntry<T>>
pub fn try_checkout(&mut self) -> Option<ExternalPoolEntry<T>>
Get an object from the pool, wrapped in an Option, if available, or None if there are
no such objects currently.
Sourcepub fn update_leases(&mut self) -> usize
pub fn update_leases(&mut self) -> usize
Update the available objects with recently returned objects. Returns the count of available objects.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Pool<T>
impl<T> RefUnwindSafe for Pool<T>
impl<T> Send for Pool<T>
impl<T> Sync for Pool<T>
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