[−][src]Struct lazy_async_pool::Pool
Lazy Asyncronous Object Pool
Implementations
impl<T, F, U, E> Pool<T, F, U, E> where
T: Send,
F: Fn() -> U,
U: Future<Output = Result<T, E>> + Unpin,
[src]
T: Send,
F: Fn() -> U,
U: Future<Output = Result<T, E>> + Unpin,
pub fn new(cap: usize, gen: F) -> Self
[src]
Generates a new pool.
Arguments
cap
- Maximum number of objects to generate.- Use
0
to make it unbounded. - The
timeout
feature can cause it to go past this limit, but extra resources will be dropped when released.
- Use
pub async fn get(self) -> Result<PoolGuard<T, F, U, E>, E>
[src]
Obtain an item from the pool. If the pool is exhausted and not at capacity, generates a new item. If the pool is exhausted and at capacity, wait for a new item to be available.
pub fn len(&self) -> usize
[src]
Number of items available in the pool.
pub fn add(&self, item: T) -> Result<(), TrySendError<T>>
[src]
Manually add a new item to the pool.
- Does not count towards the cap.
Trait Implementations
impl<T, F, U, E> Clone for Pool<T, F, U, E> where
T: Send,
F: Fn() -> U,
U: Future<Output = Result<T, E>> + Unpin,
[src]
T: Send,
F: Fn() -> U,
U: Future<Output = Result<T, E>> + Unpin,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<T, F, U, E> RefUnwindSafe for Pool<T, F, U, E> where
F: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F, U, E> Send for Pool<T, F, U, E> where
F: Send + Sync,
F: Send + Sync,
impl<T, F, U, E> Sync for Pool<T, F, U, E> where
F: Send + Sync,
F: Send + Sync,
impl<T, F, U, E> Unpin for Pool<T, F, U, E>
impl<T, F, U, E> UnwindSafe for Pool<T, F, U, E> where
F: RefUnwindSafe,
F: RefUnwindSafe,
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>,