pub struct WaitMap<K, V> { /* private fields */ }Expand description
A future-based concurrent event map with wait API.
Implementations§
Source§impl<K, V> WaitMap<K, V>
impl<K, V> WaitMap<K, V>
pub fn new() -> Self
Sourcepub async fn insert(&self, k: K, v: V) -> Option<V>
pub async 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 async fn wait(&self, k: &K) -> Option<V>where
K: Clone,
pub async fn wait(&self, k: &K) -> Option<V>where
K: Clone,
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 async fn cancel_all(&self)
pub async fn cancel_all(&self)
Cancel all key waiting tasks.
Auto Trait Implementations§
impl<K, V> !Freeze for WaitMap<K, V>
impl<K, V> !RefUnwindSafe for WaitMap<K, V>
impl<K, V> Send for WaitMap<K, V>
impl<K, V> Sync for WaitMap<K, V>
impl<K, V> Unpin for WaitMap<K, V>
impl<K, V> UnwindSafe for WaitMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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