3.2 KiB
Executor
Executes operations sequentially. Has an option for a buffer that can be triggered afterwards.
Kind: global class
- Executor
- new Executor()
- .ready :
boolean
- .queue :
Waterfall
- .buffer :
Waterfall
- ._triggerBuffer()
- .push(task, [forceQueuing])
- .pushAsync(task, [forceQueuing]) ⇒
Promise.<*>
- .processBuffer()
new Executor()
Instantiates a new Executor.
executor.ready : boolean
If this.ready is false
, then every task pushed will be buffered until this.processBuffer is called.
Kind: instance property of Executor
Access: protected
executor.queue : Waterfall
The main queue
Kind: instance property of Executor
Access: protected
executor.buffer : Waterfall
The buffer queue
Kind: instance property of Executor
Access: protected
executor._triggerBuffer()
Method to trigger the buffer processing.
Do not be use directly, use this.processBuffer
instead.
Kind: instance method of Executor
Access: protected
executor.push(task, [forceQueuing])
If executor is ready, queue task (and process it immediately if executor was idle) If not, buffer task for later processing
Kind: instance method of Executor
Param | Type | Default | Description |
---|---|---|---|
task | Object |
||
task.this | Object |
Object to use as this |
|
task.fn | function |
Function to execute |
|
task.arguments | Array |
Array of arguments, IMPORTANT: only the last argument may be a function (the callback) and the last argument cannot be false/undefined/null |
|
[forceQueuing] | Boolean |
false |
Optional (defaults to false) force executor to queue task even if it is not ready |
executor.pushAsync(task, [forceQueuing]) ⇒ Promise.<*>
If executor is ready, queue task (and process it immediately if executor was idle) If not, buffer task for later processing
Kind: instance method of Executor
Param | Type | Default |
---|---|---|
task | function |
|
[forceQueuing] | boolean |
false |
executor.processBuffer()
Queue all tasks in buffer (in the same order they came in) Automatically sets executor as ready
Kind: instance method of Executor