Struct async_singleflight::Group
source · pub struct Group<T, E>where
T: Clone,{ /* private fields */ }
Expand description
Group represents a class of work and creates a space in which units of work can be executed with duplicate suppression.
Implementations§
source§impl<T, E> Group<T, E>where
T: Clone,
impl<T, E> Group<T, E>where
T: Clone,
sourcepub async fn work(
&self,
key: &str,
fut: impl Future<Output = Result<T, E>>
) -> (Option<T>, Option<E>, bool)
pub async fn work(
&self,
key: &str,
fut: impl Future<Output = Result<T, E>>
) -> (Option<T>, Option<E>, bool)
Execute and return the value for a given function, making sure that only one operation is in-flight at a given moment. If a duplicate call comes in, that caller will wait until the original call completes and return the same value. Only owner call returns error if exists. The third return value indicates whether the call is the owner.