The JavaScript Database, for Node.js, nw.js, electron and the browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
nedb/docs/Executor.md

3.2 KiB

Executor

Executes operations sequentially. Has an option for a buffer that can be triggered afterwards.

Kind: global class

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