Struct autoreturn_pool::Pool
source · pub struct Pool<T: Send> { /* private fields */ }Expand description
A pool of objects. After an object is taken from the pool, it is returned to the pool when it is dropped.
Implementations§
source§impl<T: Send + 'static> Pool<T>
impl<T: Send + 'static> Pool<T>
sourcepub fn new<I>(items: I) -> Result<ArcPool<T>, Error>where
I: IntoIterator<Item = T>,
pub fn new<I>(items: I) -> Result<ArcPool<T>, Error>where
I: IntoIterator<Item = T>,
Objects must be sent to the pool on creation.
pub fn with_config<I>(config: Config, items: I) -> Result<ArcPool<T>, Error>where
I: IntoIterator<Item = T>,
sourcepub fn take(&self) -> Result<Option<PoolObject<T>>, Error>
pub fn take(&self) -> Result<Option<PoolObject<T>>, Error>
Take an object from the pool. If the pool is empty, wait for the specified duration.
pub fn size(&self) -> Result<usize, Error>
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