[−][src]Struct deadpool::unmanaged::Pool
A generic object and connection pool. This is the static version of the pool which does not include
This struct can be cloned and transferred across thread boundaries and uses reference counting for its internal state.
A pool of existing objects can be created from an existing collection of objects if it has a known exact size:
use deadpool::unmanaged::Pool; let pool = Pool::from(vec![1, 2, 3]);
Implementations
impl<T> Pool<T>
[src]
pub fn new(max_size: usize) -> Self
[src]
Create a new empty pool with the given max_size.
pub async fn get<'_>(&'_ self) -> Object<T>
[src]
Retrieve object from pool or wait for one to become available.
pub fn try_get(&self) -> Option<Object<T>>
[src]
Retrieve object from the pool and do not wait if there is currently no object available and the maximum pool size has been reached.
pub async fn add<'_>(&'_ self, obj: T)
[src]
Add object to pool. If the size
has already reached max_size
this function blocks until the object can be added to the pool.
pub fn try_add(&self, obj: T) -> Result<(), T>
[src]
Try to add a pool to the object. If the size
has already reached
max_size
the object is returned as Err<T>
.
pub async fn remove<'_>(&'_ self) -> T
[src]
Remove an object from the pool. This is a shortcut for
Object::take(pool.get().await)
pub fn try_remove(&self) -> Option<T>
[src]
Try to remove an object from the pool. This is a shortcut for
if let Some(obj) = self.try_get() { Some(Object::take(obj)) } else { None }
pub fn status(&self) -> Status
[src]
Retrieve status of the pool
Trait Implementations
impl<T> Clone for Pool<T>
[src]
impl<T, I> From<I> for Pool<T> where
I: IntoIterator<Item = T>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
I: IntoIterator<Item = T>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Auto Trait Implementations
impl<T> !RefUnwindSafe for Pool<T>
impl<T> Send for Pool<T> where
T: Send,
T: Send,
impl<T> Sync for Pool<T> where
T: Send,
T: Send,
impl<T> Unpin for Pool<T>
impl<T> !UnwindSafe for Pool<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,