import { AbortOptions, MaybePromise, Semaphore, Startable } from '@mithic/commons'; import { Queue } from '../queue.js'; /** A queue of async tasks. */ export declare class TaskQueue implements Startable { private readonly semaphore; private readonly queue; private paused; private _pending; private queued; constructor(semaphore?: Semaphore, queue?: Queue, autoStart?: boolean); get started(): boolean; /** Returns the total number of unfinished tasks. */ get size(): number; /** Returns the number of running but unfinished tasks. */ get pending(): number; /** Pauses further task processing. Already started tasks will keep running. */ pause(): void; start(): void; close(options?: AbortOptions): Promise; /** Adds a task to this {@link TaskQueue}. */ push(task: (options?: AbortOptions) => MaybePromise, options?: TaskOptions): Promise; /** Polls and waits for the top queue task to complete. */ poll(options?: AbortOptions): Promise; /** Tries to poll the top queue task and waits for it to complete if not throttled. */ tryPoll(): Promise | undefined; private pollLoop; private runOnceThenRelease; private runOnce; } /** A runnable task with priority in a {@link TaskQueue}. */ export declare class RunnableTask { /** The task's runnable function. */ readonly run: () => Promise; /** Priority of this task. Operations with greater priority will be scheduled first. Defaults to 0. */ readonly priority: number; constructor( /** The task's runnable function. */ run: () => Promise, /** Priority of this task. Operations with greater priority will be scheduled first. Defaults to 0. */ priority?: number); /** Returns priority of this task. */ valueOf(): number; } /** Options for a task in a {@link TaskQueue}. */ export interface TaskOptions extends AbortOptions { /** Priority of operation. Operations with greater priority will be scheduled first. Defaults to 0. */ priority?: number; } //# sourceMappingURL=task.d.ts.map