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

2.1 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.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
Params

  • task Object
    • .this Object -

      Object to use as this

    • .fn function -

      Function to execute

    • .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.<*>

Async version of [push](#Executor+push). This version is way simpler than its callbackEquivalent: you give it an async function task, it is executed when all the previous tasks are done, and then resolves or rejects and when it is finished with its original result or error.

Kind: instance method of Executor
See: Executor#push
Params

executor.processBuffer()

Queue all tasks in buffer (in the same order they came in) Automatically sets executor as ready

Kind: instance method of Executor