Expand description
Idle-gate registry — the generic armed-deadline primitive (WK.3).
A subsystem registers a handler and an armed deadline; when the
deadline elapses the editor actor runs the handler and applies the
Effects it returns. Which-key’s “hold a prefix for 300 ms” is the
first consumer; “did you mean…” hints, idle-time prefetch and the
inline-diagnostic gate are the obvious others.
§Why a registry rather than a field
This is the third instance of a shape this codebase has twice decided
is right. tick_callback’s module doc names
the alternative as the smell it exists to kill:
rather than adding an
Editor::drain_<x>method + anOption<Receiver>field per subsystem, a mode owns its channel and registers a closure that drains it.
A deadline field per subsystem is that same smell in the time domain,
and Editor::inline_diag_deadline is the existing instance of it —
a bespoke Option<Instant> on the editor plus a hand-written
select! arm in the actor. One more subsystem wanting a delay would
mean a second field and a second arm.
The inline-diagnostic gate is deliberately NOT migrated here (design
§9): its arm decision runs inside publish_render_state, reading
config, modal and cursor.line, and there is no cursor-moved
typed event to subscribe to. Finishing that migration means
publishing a CursorSettled event plus surgery on working code, and
gating a discoverability feature behind an LSP refactor is backwards.
This registry runs beside it.
§Timing
The registry stores deadlines only; it owns no timer. The actor asks
for earliest once per loop iteration
and points its single pinned sleep there, then calls
fire_elapsed when it wakes. That
keeps every tokio concern in the actor and leaves this unit
testable with a plain clock.
§Lifecycle
register returns an RAII
IdleGateHandle, mirroring TickCallbackRegistration: a mode
aggregates the handle into its Guard, so a deactivated subsystem
contributes no timer at all.
Structs§
- Idle
Gate Handle - RAII handle: arms and disarms one gate, and removes it on drop.
- Idle
Gate Registry - Registry of subsystem-contributed idle gates.
Type Aliases§
- Idle
Gate Handler - A gate’s body. Runs on the editor actor thread when the gate’s
deadline elapses; returns the
Effects the host applies. - Idle
Gate Registry Handle - Typed handle for
ServiceRegistrylookup. Per the Arc/TypeId rule, register and look up with the sameT; this alias guarantees it.