Skip to content

process.fork

Schedules a process for asynchronous execution by adding it to a queue of processes. These queued processes are intended to be executed concurrently when process.join() is called, enabling parallel processing within the script. This function allows for custom parameters to be passed to each forked process.

js
process.fork(processNameOrId)
process.fork(modelNameOrId, processNameOrId)
process.fork(processNameOrId, parameters)
process.fork(modelNameOrId, processNameOrId, parameters)

Parameters

  • modelNameOrId (string): The name or ID of the model in which the process will be forked. (optional)
  • processNameOrId (string): The name or ID of the process to fork.
  • parameters (object): An object containing parameters to be passed to the forked process. The keys represent parameter names, and the values represent the corresponding parameter values. (optional)

Returns

  • boolean: Returns true if the process was successfully forked, otherwise false.

Examples

js
// Fork a process without parameters.
var forked = process.fork("yourProcess");
console.log(forked); // true or false
js
// Fork a process within a specific model with parameters.
var parameters = { "param1": "value1", "param2": "value2" };
var forked = process.fork("yourModel", "yourProcess", parameters);
console.log(forked); // true or false