pub struct SuspendDetector { /* private fields */ }Expand description
Independent suspend detector for callers that run on their own timer and can’t
rely on the shared checkpoint()/GAP_LOG pair, which is only written by the
main tick loop. Two independently-scheduled tokio tasks that both freeze during a
host suspend become “due” at roughly the same instant on wake with no ordering
guarantee between them — a caller reading GAP_LOG right after wake can race the
main loop’s own checkpoint() call and observe no gap yet. A SuspendDetector
avoids the race by tracking its own Instant/wall-clock baseline, so it detects the
gap from its own frozen timer instead of waiting on another task to record it.
Implementations§
Source§impl SuspendDetector
impl SuspendDetector
pub fn new() -> Self
Sourcepub fn check(&mut self) -> Option<ChronoDuration>
pub fn check(&mut self) -> Option<ChronoDuration>
Record a checkpoint on this detector and return the suspend gap (if any) detected since the previous call.
Sourcepub fn gap_within(&mut self, window: Duration) -> Option<ChronoDuration>
pub fn gap_within(&mut self, window: Duration) -> Option<ChronoDuration>
Call once per wake-up. The longest suspend gap that explains a stale window of window,
from this detector’s own baseline or the shared log the main loop’s checkpoint() fills
Trait Implementations§
Source§impl Debug for SuspendDetector
impl Debug for SuspendDetector
Auto Trait Implementations§
impl Forget for SuspendDetector
impl Freeze for SuspendDetector
impl Move for SuspendDetector
impl RefUnwindSafe for SuspendDetector
impl Send for SuspendDetector
impl Sync for SuspendDetector
impl Unpin for SuspendDetector
impl UnsafeUnpin for SuspendDetector
impl UnwindSafe for SuspendDetector
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more