pub struct SingleFlight<K, 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<K, T> SingleFlight<K, T>
impl<K, T> SingleFlight<K, T>
Sourcepub fn work<F, Fut>(&self, key: K, func: F) -> impl Future<Output = T>
pub fn work<F, Fut>(&self, key: K, 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§
Auto Trait Implementations§
impl<K, T> Freeze for SingleFlight<K, T>
impl<K, T> !RefUnwindSafe for SingleFlight<K, T>
impl<K, T> Send for SingleFlight<K, T>
impl<K, T> Sync for SingleFlight<K, T>
impl<K, T> Unpin for SingleFlight<K, T>
impl<K, T> !UnwindSafe for SingleFlight<K, 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