/** * @module defer-timer * @category Internal * * The shared "next visit time" primitive (#1090). A `DeferTimer` holds a * `stream → due-time` map and a single collapsed wake timer: it parks * streams that should be re-visited later and fires one `on_wake` callback * at the earliest pending due-time, garbage-collecting the entries that have * come due. * * Two consumers ride it: * * - the {@link "drain-cycle".DrainController} — for per-reaction backoff (a * retry's `next_attempt_at`) and, once handlers can express it, the * `defer` outcome that holds a stream pending without advancing the * watermark or bumping `retry`. * - the autoclose controller — to schedule its next eligibility check at the * precise time an `after`-style cooldown elapses, instead of a blind * fixed-interval sweep. * * Lives in process memory, per worker — the same per-worker pacing trade-off * documented for backoff. Durability comes from the data the due-time is * *derived* from (an un-advanced watermark, an event's `created` timestamp), * not from the map. A restart empties the map, so the cold-start rebuild is * explicit: `CorrelateCycle.init` seeds each still-future `deferred_at` back * onto the owning lane's timer via {@link "drain-cycle".DrainController.seed_defer} * (#1221), so an idle deferred stream re-arms at its due-time with no * intervening commit. * * @internal */ export declare class DeferTimer { private readonly _due; private _timer; private readonly _on_wake; /** * @param on_wake - invoked once each time the earliest due-time elapses, * after the come-due entries have been removed. Consumers use it to * re-arm their loop (the drain sets its `armed` flag; autoclose runs a * tick). */ constructor(on_wake: () => void); /** Number of currently parked streams. */ get size(): number; /** * True while `stream` is parked with a due-time still in the future. * Consumers skip work for deferred streams until their window elapses. */ is_deferred: (stream: string) => boolean; /** * Park `stream` for a re-visit at `at` (ms since epoch). A plain * overwrite: the caller computes the authoritative next-visit for the * stream (the drain's `handle` already reconciles a stream's reactions * into one result per cycle), so there is no stale value to merge against. */ set(stream: string, at: number): void; /** Drop `stream` from the parked set (e.g. on a successful ack or block). */ delete(stream: string): void; /** * (Re)schedule the wake timer at the earliest pending due-time. Idempotent * — collapses many parked streams into a single timer. A no-op clears any * pending timer when the map is empty. * * The timer is `unref()`-ed so pending re-visits never keep the process * alive on their own. */ schedule(): void; /** Cancel any pending wake timer. Idempotent. Leaves the parked set intact. */ stop(): void; } //# sourceMappingURL=defer-timer.d.ts.map