pub struct KeyedLimiter<K: Eq + Hash + Clone> { /* private fields */ }Expand description
Limit the concurrency of some keyed operation without blocking.
Implementations§
Source§impl<K: Eq + Hash + Clone> KeyedLimiter<K>
impl<K: Eq + Hash + Clone> KeyedLimiter<K>
Sourcepub fn new(max: NonZeroU32) -> Self
pub fn new(max: NonZeroU32) -> Self
Create a limiter that allows up to max concurrent reservations.
Sourcepub fn try_acquire(&self, key: K) -> Option<KeyedReservation<K>>
pub fn try_acquire(&self, key: K) -> Option<KeyedReservation<K>>
Attempt to reserve a slot for a given key. Returns None when the limiter is saturated or
the key is already reserved.
Auto Trait Implementations§
impl<K> Freeze for KeyedLimiter<K>
impl<K> RefUnwindSafe for KeyedLimiter<K>
impl<K> Send for KeyedLimiter<K>where
K: Send,
impl<K> Sync for KeyedLimiter<K>where
K: Send,
impl<K> Unpin for KeyedLimiter<K>
impl<K> UnwindSafe for KeyedLimiter<K>
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