Class TaskQueue<PriorityType>

A TaskQueue runs actions in a sequence, with the ability to abort the queued tasks.

Type Parameters

  • PriorityType = undefined

Constructors

Properties

Accessors

Methods

Constructors

Properties

A comparator for comparing two task priorities.

defaultPriority: PriorityType

The default priority if not provided. If comparator is nullish priority values will have no effect.

Accessors

  • get running(): number
  • How many tasks are currently running.

    Returns number

  • get simultaneous(): number
  • Returns number

  • set simultaneous(value): void
  • How many simultaneous tasks may be run at a time. Reducing this will not abort currently running tasks.

    Parameters

    • value: number

    Returns void

Methods

  • Aborts all enqueued operations.

    Parameters

    • reason: Error = ...

    Returns void

  • Enqueues the given task, returning a Promise that settles when the task is complete.

    Type Parameters

    • T

    Parameters

    • task: Task<T>

      A function that is optionally asynchronous.

    • priority: PriorityType = ...

      The priority of the task. If not provided, defaultPriority() will be used.

    Returns Promise<T>