pub struct KeyWaitMap<K, V> { /* private fields */ }
Expand description
A future-based concurrent event map with wait
API.
Implementations§
Source§impl<K, V> KeyWaitMap<K, V>
impl<K, V> KeyWaitMap<K, V>
pub fn new() -> Self
Sourcepub fn insert(&self, k: K, v: V) -> Option<V>
pub fn insert(&self, k: K, v: V) -> Option<V>
Inserts a event-value pair into the map.
If the map did not have this key present, None is returned.
Sourcepub fn batch_insert<I>(&self, kv: I)
pub fn batch_insert<I>(&self, kv: I)
Inserts a event-value pair into the map.
If the map did not have this key present, None is returned.
Sourcepub async fn wait<L>(&self, k: &K, locker: L) -> Option<V>
pub async fn wait<L>(&self, k: &K, locker: L) -> Option<V>
Create a key waiting task until a value is put under the key, only one waiting task for a key can exist at a time.
Returns the value at the key if the key was inserted into the map,
or returns None
if the waiting task is canceled.
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Cancel all key waiting tasks.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> !Freeze for KeyWaitMap<K, V>
impl<K, V> RefUnwindSafe for KeyWaitMap<K, V>
impl<K, V> Send for KeyWaitMap<K, V>
impl<K, V> Sync for KeyWaitMap<K, V>
impl<K, V> Unpin for KeyWaitMap<K, V>
impl<K, V> UnwindSafe for KeyWaitMap<K, V>
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