import { Task } from './AsyncTask.js'; import CancelablePromise from './CancelablePromise.js'; import './Promise.js'; interface ScheduledTask { cb: (...args: any[]) => any; canceled?: boolean; cancel: () => void; internalCancel?: () => void; resolve(value: any): void; reject(reason: any): void; } declare const _tasks: unique symbol; declare const _currentTask: unique symbol; declare const _asyncTask: unique symbol; /** * The BlockingTaskExecutor is a task execution list, which executes tasks one after another. * The difference to the {@link TaskExecutor} is that it only uses macro tasks and that task executions can be tracked * by clients. * @example * ```ts * const executor = new BlockingTaskExecutor(); * const task = () => { doSomething(); }; // ... }; * // execute the task if others pushed before are finished. * const result = await executor.push(task); * ``` */ declare class BlockingTaskExecutor { [_tasks]: ScheduledTask[]; [_asyncTask]: Task<[], void | undefined>; [_currentTask]: ScheduledTask | undefined; /** * Number of waiting tasks. */ get length(): number; /** * Add a task to the executor. * * @param {function} callback the task to execute. * @returns {CancelablePromise} the promise of the task */ push(callback: (...args: Args) => Result | PromiseLike): CancelablePromise; /** * Cancels all tasks in the queue, as well as the currently running one. */ cancel(): void; } export { BlockingTaskExecutor, BlockingTaskExecutor as default };