Multithreading toolkit
Install:
npm install multithreading-toolkit --save
workerThreadsFunction
- Execution of a function in a separate thread (based on worker_threads module). Available for Node.js version 10.5.0 and higher.
workerThreadsFunction args:
source
: Function or path to the module that exports the function (Function/String)options
: Options when creating a function (Object):options.returnTimeout
: Return timeout (milliseconds) (Default: 60000)options.eval
:true
, if the function was passed as the source,false
if the path to the module was passed as the source (Default: false)options.execArgv
: execArgv forWorker
instance (Array) (Default: [])options.pool
: Do I need to use a pool of workers (Bool) (Default: false)options.poolOptions
: Pool options for generic-pool
Example:
'use strict'; const myReturnTimeout = 1000000;const workerThreadsFunction = ; const someFunction = ; // Call the function, passing in an array of arguments;
forkFunction
- Execution of a function in a separate thread (based on child_process.fork).
forkFunction args:
source
: Function or path to the module that exports the function (Function/String)options
: Options when creating a function (Object):options.returnTimeout
: Return timeout (milliseconds) (Default: 60000)options.eval
:true
, if the function was passed as the source,false
if the path to the module was passed as the source (Default: false)options.forkOptions
: options for child_process.forkoptions.pool
: Do I need to use a pool of workers (Bool) (Default: false)options.poolOptions
: Pool options for generic-pool
Example:
'use strict'; const myReturnTimeout = 1000000;const forkFunction = ; const someFunction = ; // Call the function, passing in an array of arguments;