/** * Seconds one guest occupies the head of the line before any boarding interval has been measured. * A bootstrap only: the estimate switches to the queue's own measured throughput as soon as two * boardings have been observed. */ export declare const DEFAULT_QUEUE_SEED_SERVICE_SECONDS = 8; /** Boarding events the throughput window keeps. */ export declare const DEFAULT_QUEUE_WINDOW = 8; /** One guest waiting their turn, and when they joined the line. */ export interface QueueEntry { readonly id: string; readonly joinedAt: number; } /** A wait estimate read off the queue's own measured throughput. */ export interface QueueWait { /** Guests in front of the reader (the whole line for a new arrival). */ readonly ahead: number; /** Seconds that wait. */ readonly seconds: number; /** Seconds one guest spends at the head; the seed until an interval has been measured. */ readonly perGuestSeconds: number; /** Guests boarded per second over the measured window; `0` before any interval is observed. */ readonly throughput: number; /** True while the estimate still rests on the seed rather than a measured interval. */ readonly seeded: boolean; } /** Tunables for {@link createWaitQueue}, every one retunable through a restore. */ export interface WaitQueueOptions { /** Seconds per guest used before the queue has measured an interval. Default 8. */ readonly seedServiceSeconds?: number; /** Boarding events the throughput window keeps. Default 8. */ readonly window?: number; /** Register a devtools probe under this name so the perf overlay shows the live line. */ readonly devtoolsName?: string; } /** Serializable line state: who is waiting, and the boardings the estimate is measured from. */ export interface WaitQueueSnapshot { entries: QueueEntry[]; boards: { at: number; count: number; }[]; seedServiceSeconds: number; window: number; } /** * A real line: guests join the back, leave the head, and the wait a new arrival faces comes from how * fast this queue has actually been boarding — not from a configured constant. A broken ride stops * boarding, the line grows, and the estimate grows with it. */ export interface WaitQueue { /** Join the back of the line; false when the id is already waiting. */ enqueue(id: string, now: number): boolean; /** Leave from anywhere in the line. */ remove(id: string): boolean; has(id: string): boolean; /** 0-based place in line, or `-1` when not waiting. */ positionOf(id: string): number; /** When the guest joined, or `null` when not waiting. */ joinedAt(id: string): number | null; size(): number; headId(): string | null; /** Id at a 0-based index from the head, or `null` past the end. */ at(index: number): string | null; /** Everyone in line, head first. Allocates — debug and tests. */ ids(): readonly string[]; /** Take the guest at the head, or `null` when the line is empty. */ dequeue(): string | null; /** Record that `count` guests left the head at `now`; the throughput window reads these. */ recordBoard(now: number, count: number): void; /** * Wait facing `id`, or the whole line when `id` is omitted or not waiting — what a guest joining * now would face. */ wait(id?: string): QueueWait; snapshot(): WaitQueueSnapshot; restore(next: WaitQueueSnapshot): void; /** Drop the devtools probe registered by `devtoolsName`. Safe to call twice. */ dispose(): void; } /** * Create a line whose wait estimate is derived from its own throughput. The queue owns the order and * the measurement; the ride owns how fast guests are taken off the head, so a slower cycle raises the * estimate without the queue being told a cycle time. * * `enqueue` is O(1) and `dequeue` amortized O(1) — a long line never re-indexes. * * @capability wait-queue a real line whose wait estimate comes from its own measured throughput */ export declare function createWaitQueue(options?: WaitQueueOptions): WaitQueue;