Struct simple_pool::ResourcePool
source · pub struct ResourcePool<T> {
pub holder: Arc<Mutex<ResourceHolder<T>>>,
}Expand description
Versatile resource pool
Fields§
§holder: Arc<Mutex<ResourceHolder<T>>>Implementations§
source§impl<T> ResourcePool<T>
impl<T> ResourcePool<T>
sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Create new resource pool with pre-allocated capacity
The size parameter is used to pre-allocate memory for the resource holder only
sourcepub fn append(&self, res: T)
pub fn append(&self, res: T)
Append resource to the pool
Panics
This function might panic when called if the resource lock is already held by the current thread
sourcepub async fn get(&self) -> ResourcePoolGuard<T>
pub async fn get(&self) -> ResourcePoolGuard<T>
Get resource from the pool or wait until one is available
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for ResourcePool<T>
impl<T> Send for ResourcePool<T>where T: Send,
impl<T> Sync for ResourcePool<T>where T: Send,
impl<T> Unpin for ResourcePool<T>
impl<T> UnwindSafe for ResourcePool<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