export interface ThreadQueueOpts {
    /** Called once if this run had to wait. `ahead` is the number of runs
     *  queued before this one (0 = this is the new tail with nobody waiting,
     *  1 = one predecessor in flight, etc.). Use this to notify the user
     *  that their message was received but is queued. Fired before the
     *  wait begins. Throwing in the callback is swallowed. */
    onQueued?: (ahead: number) => void | Promise<void>;
}
/** Run `fn` while holding the per-key serial lock. Subsequent calls with
 *  the same key wait until prior ones settle (success or failure). The
 *  promise-chain pattern guarantees FIFO ordering. */
export declare function runOnThread<T>(key: string, fn: () => Promise<T>, opts?: ThreadQueueOpts): Promise<T>;
/** Current queue depth for a key. 0 when nothing in flight or waiting. */
export declare function getQueueDepth(key: string): number;
/** Reset all queues. Test-only. */
export declare function _resetThreadQueues(): void;
//# sourceMappingURL=thread-queue.d.ts.map