TaskStackSync

Used to run many sync/async functions sequentially. Only one task is run at a time, so the results do not need to be buffered and ordered. Also to keep the class simple, there is no queue limit imposed. This is equivalent to either TaskStackAsync or TaskLimiter with running_limit = 1 and queued_limit = Infinity. For full control, you can use those alternatives.

Note that while this runs tasks "synchronously" all tasks are converted to async functions, as tasks may not be run immediately, instead queued in the stack.

Constructor

new TaskStackSync(listeneropt, nullable)

Create a new TaskStackSync

Parameters:
NameTypeAttributesDefaultDescription
listenerStackListener<optional>
<nullable>
null

listener for task results; optional for this class, since you can be guaranteed tasks are run sequentially

Classes

TaskStackSync

Members

(nullable) listener :StackListener

Listener for results

Methods

add(task, …args)

Adds another task to be run

Parameters:
NameTypeAttributesDescription
taskfunction | Promise
argsany<repeatable>

arguments to pass to the TaskStackSync#listener (not the task!)

empty() → {Promise}

Returns promise which resolves when stack is empty

Returns:
Type: 
Promise