Skip to main content

KeyedPool

Struct KeyedPool 

Source
pub struct KeyedPool<K: 'static, A: 'static, E: 'static> { /* private fields */ }
Expand description

Pool partitioned by key; total concurrent checkouts across all keys is bounded by capacity.

Implementations§

Source§

impl<K, A, E> KeyedPool<K, A, E>
where K: Clone + Eq + Hash + Send + Sync + 'static, A: Clone + PartialEq + Send + Sync + 'static, E: Send + Sync + 'static,

Source

pub fn make<F>(capacity: usize, factory: F) -> Effect<Self, Never, ()>
where F: Fn(K) -> Effect<A, E, ()> + Send + Sync + 'static,

Build a keyed pool with global capacity and per-key factory for new values.

Source

pub fn make_with_ttl<F>( capacity: usize, ttl: Duration, factory: F, ) -> Effect<Self, Never, ()>
where F: Fn(K) -> Effect<A, E, ()> + Send + Sync + 'static,

Same as Self::make, but idle slots older than ttl are discarded on checkout.

Source

pub fn invalidate(&self, key: K, item: A) -> Effect<(), Never, ()>

Mark (key, item) as not reusable for that key; drops matching idle entries.

Source

pub fn get(&self, key: K) -> Effect<A, E, Scope>

Checkout a value for key: acquires global capacity, then reuses idle or runs factory.

Trait Implementations§

Source§

impl<K: Clone + 'static, A: Clone + 'static, E: Clone + 'static> Clone for KeyedPool<K, A, E>

Source§

fn clone(&self) -> KeyedPool<K, A, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<K, A, E> Freeze for KeyedPool<K, A, E>

§

impl<K, A, E> !RefUnwindSafe for KeyedPool<K, A, E>

§

impl<K, A, E> Send for KeyedPool<K, A, E>
where K: Send, A: Send,

§

impl<K, A, E> Sync for KeyedPool<K, A, E>
where K: Send, A: Send,

§

impl<K, A, E> Unpin for KeyedPool<K, A, E>

§

impl<K, A, E> UnsafeUnpin for KeyedPool<K, A, E>

§

impl<K, A, E> !UnwindSafe for KeyedPool<K, A, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.