pub struct RecyclePool<T: Recyclable + Default> { /* private fields */ }Expand description
Generic object pool with recycling support.
This pool maintains a set of pre-allocated objects that can be acquired, used, and returned for reuse.
Implementations§
Source§impl<T: Recyclable + Default> RecyclePool<T>
impl<T: Recyclable + Default> RecyclePool<T>
Sourcepub fn with_config(capacity: usize, config: RecyclePoolConfig) -> Self
pub fn with_config(capacity: usize, config: RecyclePoolConfig) -> Self
Create with custom configuration.
Sourcepub fn acquire(&mut self) -> Option<PoolHandle<'_, T>>
pub fn acquire(&mut self) -> Option<PoolHandle<'_, T>>
Acquire an object from the pool.
Returns a handle that automatically returns the object when dropped.
Sourcepub fn try_acquire(&mut self) -> Option<PoolHandle<'_, T>>
pub fn try_acquire(&mut self) -> Option<PoolHandle<'_, T>>
Try to acquire without blocking.
Sourcepub fn high_water_mark(&self) -> usize
pub fn high_water_mark(&self) -> usize
Get high water mark.
Sourcepub fn reset_high_water_mark(&mut self)
pub fn reset_high_water_mark(&mut self)
Reset high water mark.
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Check if pool is exhausted.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for RecyclePool<T>
impl<T> RefUnwindSafe for RecyclePool<T>where
T: RefUnwindSafe,
impl<T> Send for RecyclePool<T>where
T: Send,
impl<T> Sync for RecyclePool<T>where
T: Sync,
impl<T> Unpin for RecyclePool<T>where
T: Unpin,
impl<T> UnwindSafe for RecyclePool<T>where
T: UnwindSafe,
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> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Returns the TypeId of this type (for internal use)
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Returns the type name for debugging