pub struct Debouncer { /* private fields */ }Expand description
Per-session debounce controller.
State is two atomics — an epoch counter bumped on every
Self::poke, and a pending flag that gates spawning the
debounce task. The task itself is lazy: it spawns on the
first poke after an idle period, sleeps the debounce
window, re-reads the epoch, and either re-sleeps (more pokes
arrived during the window) or invokes the supplied
runner and exits. No task runs while the session is
quiescent.
runner is Arc<dyn Fn> — shareable across the loop. The
caller (DiffSubsystem::poke_session) captures the
subsystem Arc + session key into the closure.
Implementations§
Source§impl Debouncer
impl Debouncer
pub fn new(window: Duration) -> Self
pub fn window(&self) -> Duration
Sourcepub fn poke<F>(&self, runner: F)
pub fn poke<F>(&self, runner: F)
Bump the epoch. If no debounce task is in flight, spawn
one that sleeps the window, re-reads the epoch, and
either re-sleeps (more pokes) or invokes runner and
exits.
runner runs on the tokio runtime (the debounce task is
itself a tokio task). Inside the runner, the production
call site schedules the actual recompute on
spawn_blocking; the runner closure stays light.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Debouncer
impl RefUnwindSafe for Debouncer
impl Send for Debouncer
impl Sync for Debouncer
impl Unpin for Debouncer
impl UnsafeUnpin for Debouncer
impl UnwindSafe for Debouncer
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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