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.