Struct singleflight_async::SingleFlight
source · pub struct SingleFlight<T> { /* private fields */ }Expand description
SingleFlight represents a class of work and creates a space in which units of work can be executed with duplicate suppression.
Implementations§
source§impl<T> SingleFlight<T>
impl<T> SingleFlight<T>
sourcepub fn work_with_owned_key<F, Fut>(
&self,
key: Cow<'static, str>,
func: F,
) -> impl Future<Output = T>
pub fn work_with_owned_key<F, Fut>( &self, key: Cow<'static, str>, func: F, ) -> impl Future<Output = T>
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 key is a Owned key. The performance will be slightly better than work.
sourcepub fn work<F, Fut>(&self, key: &str, func: F) -> impl Future<Output = T>
pub fn work<F, Fut>(&self, key: &str, func: F) -> impl Future<Output = T>
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.
Trait Implementations§
source§impl<T: Debug> Debug for SingleFlight<T>
impl<T: Debug> Debug for SingleFlight<T>
Auto Trait Implementations§
impl<T> Freeze for SingleFlight<T>
impl<T> !RefUnwindSafe for SingleFlight<T>
impl<T> Send for SingleFlight<T>where
T: Send,
impl<T> Sync for SingleFlight<T>where
T: Send,
impl<T> Unpin for SingleFlight<T>
impl<T> !UnwindSafe for SingleFlight<T>
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