@vgerbot/async
    Preparing search index...

    Interface PriorityTaskQueue<T, R>

    Priority task queue interface extending the base TaskQueue. Tasks with higher priority values are processed first.

    interface PriorityTaskQueue<T, R> {
        idle: boolean;
        length: number;
        paused: boolean;
        running: number;
        cancel(reason?: unknown): void;
        isCancelled(): boolean;
        onEmpty(): Promise<void>;
        onError(): Promise<QueueTaskError<T>>;
        onIdle(): Promise<void>;
        onSaturated(): Promise<void>;
        onSizeLessThan(size: number): Promise<void>;
        pause(): void;
        push(task: T, priority?: number): Promise<R>;
        pushMany(tasks: T[], priority?: number): Promise<R[]>;
        resume(): void;
    }

    Type Parameters

    • T
    • R

    Hierarchy

    • Omit<TaskQueue<T, R>, "push" | "pushMany">
      • PriorityTaskQueue
    Index

    Properties

    idle: boolean

    True when both length and running are zero.

    length: number

    Number of queued tasks waiting to be processed.

    paused: boolean

    True when scheduling is paused.

    running: number

    Number of tasks currently executing.

    Methods

    • Resolves when the queue becomes idle (no pending and no running tasks). If already idle, resolves immediately.

      Returns Promise<void>

    • Resolves when queued task count becomes less than the provided threshold.

      Parameters

      • size: number

      Returns Promise<void>

    • Enqueues a single task with optional priority.

      Parameters

      • task: T

        The task to enqueue.

      • Optionalpriority: number

        Priority value (higher = processed first). Default: 0.

      Returns Promise<R>

      A promise that resolves/rejects with the worker outcome.

    • Enqueues multiple tasks with the same priority.

      Parameters

      • tasks: T[]

        Array of tasks to enqueue.

      • Optionalpriority: number

        Priority value for all tasks. Default: 0.

      Returns Promise<R[]>

      A promise resolving to results in input order.