helpers.taskQueues.ParallelPriorityTaskQueue - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Class: ParallelPriorityTaskQueue

helpers.taskQueues.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

Constructors

constructor

new ParallelPriorityTaskQueue()

Properties

maxParallel

maxParallel: number = 1


usePriority

usePriority: boolean = true

Accessors

length

get length(): number

Returns

number

Methods

execute

execute<T>(func, args, priority?, cancel?): NopePromise<T, any>

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

Name
T

Parameters

Name Type Default value
func (...args: any[]) => T | Promise<T> undefined
args any[] undefined
priority number 0
cancel () => void undefined

Returns

NopePromise<T, any>

⚠️ **GitHub.com Fallback** ⚠️