pub struct SingleFlight { /* private fields */ }Expand description
Guard for a single-flight fill, returned by
CacheKit::single_flight.
Holds the per-key in-process lock for its whole lifetime, and the
distributed fill lock (if one was acquired) until Self::release.
Dropping without release is safe: the in-process lock frees immediately
and a distributed lock expires server-side after its timeout.
Implementations§
Source§impl SingleFlight
impl SingleFlight
Sourcepub async fn wait_for_fill(&mut self) -> bool
pub async fn wait_for_fill(&mut self) -> bool
true while another worker may still be filling this key — re-check
the cache after every true before computing yourself:
- Leader: immediately
false(compute, don’t re-read your own miss). - Queued behind a local leader:
trueexactly once. - Contested cross-process: sleeps one poll interval per call,
trueuntil the poll budget is spent.
Auto Trait Implementations§
impl !RefUnwindSafe for SingleFlight
impl !UnwindSafe for SingleFlight
impl Freeze for SingleFlight
impl Send for SingleFlight
impl Sync for SingleFlight
impl Unpin for SingleFlight
impl UnsafeUnpin for SingleFlight
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