Struct async_singleflight::UnaryGroup
source · pub struct UnaryGroup<T>where
T: Clone,{ /* private fields */ }
Expand description
UnaryGroup represents a class of work and creates a space in which units of work can be executed with duplicate suppression.
Implementations§
source§impl<T> UnaryGroup<T>where
T: Clone + Send + Sync,
impl<T> UnaryGroup<T>where
T: Clone + Send + Sync,
sourcepub fn new() -> UnaryGroup<T>
pub fn new() -> UnaryGroup<T>
Create a new Group to do work with.
sourcepub fn work<'s>(
&'s self,
key: &'s str,
fut: impl Future<Output = T> + Send + 's
) -> BoxFuture<'s, (T, bool)>
pub fn work<'s>(
&'s self,
key: &'s str,
fut: impl Future<Output = T> + Send + 's
) -> BoxFuture<'s, (T, 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.
The third return value indicates whether the call is the owner.