Pool

Struct Pool 

Source
pub struct Pool<K, I> { /* private fields */ }
Expand description

A keep-alive connection pool.

Implementations§

Source§

impl<K, I> Pool<K, I>
where K: Eq + Hash,

Source

pub fn new(capacity: usize) -> Self

Creates a new connection pool with the given limit.

Source

pub fn new_unbounded() -> Self

Creates a new connection pool with no limit.

Source

pub fn set_local_limit(&self, limit: usize) -> usize

Sets a local limit for a key. Returns the index for the local limit.

Source

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.

Source

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.

Source

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.

Source

pub fn try_pull(&self, key: K) -> Option<Item<K, I>>

Attempts to pull an item from the pool. This method returns None, when the global limit is reached.

Source

pub fn try_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 returns None, 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>
where I: Sync + Send, K: Sync + Send,

§

impl<K, I> Sync for Pool<K, I>
where I: Sync + Send, K: Sync + Send,

§

impl<K, I> Unpin for Pool<K, I>

§

impl<K, I> !UnwindSafe for Pool<K, I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.