clean-jsdoc-theme API

forge/queue

Source: queue.js:7

The event-driven task Queue and its supporting types.


Other

Task

A unit of work the Queue can run.

Properties

  • id (string) — Stable identifier for the task.
  • priority (Priority, optional, default: "Priority.NORMAL") — Relative scheduling weight.
  • run (TaskHandler) — The function invoked when the task is scheduled.

Type

Object

TaskHandler

The function a Task runs when scheduled.

Parameters

  • signal (AbortSignal) — Aborted if the queue is cleared mid-flight.

Returns

  • Promise.<void> | void — Resolves when the task is complete.

MAX_CONCURRENCY

Maximum concurrency the queue will ever allow, regardless of options.

Type

number

Queue

Extends: EventEmitter

An ordered, event-driven task runner.

Queue extends Node's EventEmitter, so the inheritance chain and the emitted events both show up in the generated page.

Tasks pushed after Queue#clear runs are rejected — clearing aborts the in-flight signal.

Parameters

  • options (Object, optional, default: "{}") — Queue configuration.
    • options.concurrency (number, optional, default: 1) — How many tasks run at once (clamped to MAX_CONCURRENCY).
    • options.autoStart (boolean, optional, default: true) — Start draining as soon as a task is pushed.

Fires

  • Queue#event:drain
  • Queue#event:error

Listens

  • module:forge/cache.Cache#event:evict

Example

Draining a queue

CODE
const q = new Queue({ concurrency: 2 });
q.on('drain', () => console.log('done'));
q.push({ id: 't1', run: async () => doWork() });
await q.drain();
  • Since: 1.1.0
  • Version: 1.3.0
  • Copyright: 2024 The clean-jsdoc-theme team
  • Author: The clean-jsdoc-theme team
  • Requires: module:forge/cache
  • TODO:
    • Add backpressure when the pending list exceeds a high-water mark.