pub struct Pool<K, I> { /* private fields */ }Expand description
A keep-alive connection pool.
Implementations§
Source§impl<K, I> Pool<K, I>
impl<K, I> Pool<K, I>
Sourcepub fn new_unbounded() -> Self
pub fn new_unbounded() -> Self
Creates a new connection pool with no limit.
Sourcepub fn set_local_limit(&self, limit: usize) -> usize
pub fn set_local_limit(&self, limit: usize) -> usize
Sets a local limit for a key. Returns the index for the local limit.
Sourcepub async fn pull(&self, key: K) -> Item<K, I>
pub async fn pull(&self, key: K) -> Item<K, I>
Pulls an item from the pool. This method waits, when the global limit is reached.
Sourcepub async fn pull_with_local_limit(
&self,
key: K,
local_limit_index: Option<usize>,
) -> Option<Item<K, I>>
pub async fn pull_with_local_limit( &self, key: K, local_limit_index: Option<usize>, ) -> Option<Item<K, I>>
Attempts to pull an item from the pool (with local limit applied).
This method waits, when the global limit is reached, and returns None, when a local limit is reached.
Sourcepub async fn pull_with_wait_local_limit(
&self,
key: K,
local_limit_index: Option<usize>,
) -> Item<K, I>
pub async fn pull_with_wait_local_limit( &self, key: K, local_limit_index: Option<usize>, ) -> Item<K, I>
Pulls an item from the pool (with local limit applied). This method waits, when either the global limit or a local limit is reached.
Auto Trait Implementations§
impl<K, I> !Freeze for Pool<K, I>
impl<K, I> !RefUnwindSafe for Pool<K, I>
impl<K, I> Send for Pool<K, I>
impl<K, I> Sync for Pool<K, I>
impl<K, I> Unpin for Pool<K, I>
impl<K, I> !UnwindSafe for Pool<K, I>
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