pub struct Group<K, V> { /* private fields */ }Expand description
A Group represents a namespace in which work can be deduplicated by key.
Only one caller per key executes the function; concurrent callers for the same key receive the same result once it is ready.
§Panics
The function passed to call_async must not panic.
If it panics, all waiting callers will hang forever because the value will
never be stored and they will never be notified.
Implementations§
Source§impl<K, V> Group<K, V>
impl<K, V> Group<K, V>
Sourcepub async fn call_async<F, Fut>(&self, key: K, f: F) -> Call<V>
pub async fn call_async<F, Fut>(&self, key: K, f: F) -> Call<V>
Executes f for the given key, coalescing duplicate callers.
If no other call is in-flight for key, this call executes f and
returns its result with shared = false.
If another call for the same key is already in-flight, this call
awaits that call’s completion and returns the same result with
shared = true.
§Panics
f must not panic. See the type-level docs.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for Group<K, V>
impl<K, V> RefUnwindSafe for Group<K, V>
impl<K, V> Send for Group<K, V>
impl<K, V> Sync for Group<K, V>
impl<K, V> Unpin for Group<K, V>
impl<K, V> UnsafeUnpin for Group<K, V>
impl<K, V> UnwindSafe for Group<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