import { Task as Task$1 } from './AsyncTask.js'; import ExtendedPromise from './Promise.js'; import './CancelablePromise.js'; declare const _tasks: unique symbol; declare const _flusher: unique symbol; declare const _flushTriggered: unique symbol; declare const _microTasks: unique symbol; declare const _currentTask: unique symbol; /** Represents tasks executed by the TaskExecutor. */ interface Task { /** Executes the task */ (): void; /** Returns true if `this` equals `other`. */ equals?(other: Task): boolean; } /** * The TaskExecutor is a task execution list, tasks can be added and will be executed one after another. * Implementation hint: Pushed task are queued and executed as micro tasks in the next event queue slot. * * @example _Use default export_ * ```ts * import TaskExecutor from "apprt-core/TaskExecutor"; * const executor = new TaskExecutor(); * const task = function(){ doSomething(); }; * // execute the task as fast as possible * executor.push(task); * // add again (will drop the old add, as long as the task was not executed) * executor.push(task); * ``` */ declare class TaskExecutor { readonly delay: number; [_tasks]: Task[]; [_microTasks]: Task[]; [_flusher]: Task$1<[], void>; [_flushTriggered]: boolean; [_currentTask]: ExtendedPromise | undefined; constructor(delay?: number); /** * Number of waiting tasks. */ get length(): number; /** * Add a task to the executor. * If the task is already queued then the old is removed. * A custom `task.equals' method can modify the behavior. * * @param task the task to execute. */ push(task: Task): void; /** * Removes task from the list. * The task.equals method can customize which tasks are removed. * @param task the task to remove */ remove(task: Partial | (() => void)): void; } export { TaskExecutor, TaskExecutor as default }; export type { Task };