import { Disposable } from 'vscode'; export interface ITask { (): T; } export declare class Delayer { defaultDelay: number; private timeout; private completionPromise; private onSuccess; private task; constructor(defaultDelay: number); trigger(task: ITask, delay?: number): Promise; private cancelTimeout; } export declare function setImmediate(callback: (...args: unknown[]) => void, ...args: unknown[]): Disposable; /** * A helper to prevent accumulation of sequential async tasks. * * Imagine a mail man with the sole task of delivering letters. As soon as * a letter submitted for delivery, he drives to the destination, delivers it * and returns to his base. Imagine that during the trip, N more letters were submitted. * When the mail man returns, he picks those N letters and delivers them all in a * single trip. Even though N+1 submissions occurred, only 2 deliveries were made. * * The throttler implements this via the queue() method, by providing it a task * factory. Following the example: * * const throttler = new Throttler(); * const letters = []; * * function deliver() { * const lettersToDeliver = letters; * letters = []; * return makeTheTrip(lettersToDeliver); * } * * function onLetterReceived(l) { * letters.push(l); * throttler.queue(deliver); * } */ export declare class Throttler { private activePromise; private queuedPromise; private queuedPromiseFactory; private isDisposed; constructor(); queue(promiseFactory: ITask>): Promise; dispose(): void; } export declare function raceTimeout(promise: Promise, timeout: number, onTimeout?: () => void): Promise; //# sourceMappingURL=async.d.ts.map