Class ParallelPriorityTaskQueue

A Task-Queue. This could be used to make parallel Request run sequentially. For Instance during Saving and Reading Vars to achive a consistent set of Data.

Usage:

 // Create a Queue
const _queue = new PriorityTaskQueue();
// Create a Function
const _func = (_input: string, _cb) => {
console.log("Hallo ", _input)
_cb(null, null);
}

const promises = [
_queue.execute(_func, ['Welt priority=0'],0),
_queue.execute(_func, ['Welt priority=1'],1),
_queue.execute(_func, ['Welt priority=2'],2) *
];

// => Hallo Welt priority=0 <- Startet directly.
// => Hallo Welt priority=2 <- Startet because it has the highest priority.
// => Hallo Welt priority=1

Export

Hierarchy

  • ParallelPriorityTaskQueue

Constructors

Properties

Accessors

Methods

Constructors

Properties

maxParallel: number = 1
usePriority: boolean = true

Accessors

Methods

  • Executes the given Task. If now Task is running it is executed immediatelly, otherwise it is pushed in the queue and call if the other tasks are call.

    Memberof

    TaskQeue

    Type Parameters

    • T

    Parameters

    • func: ((...args) => T | Promise<T>)
        • (...args): T | Promise<T>
        • Parameters

          • Rest ...args: any[]

          Returns T | Promise<T>

    • args: any[]
    • priority: number = 0
    • cancel: (() => void) = ...
        • (): void
        • Returns void

    Returns NopePromise<T, any>

Generated using TypeDoc