multiThreading

Runs another NodeJS program in a seperate thread.

virtuosity.multiThreading

Classes

Methods


Classes

Thread

Creates a separate run thread (multithreading)

new virtuosity.multiThreading.Thread(path, onMessage, onExit);


Parameter Type Description
path String path to the file to run in the thread
onMessage Function action to complete when the thread sends a message using process.send(data)
onExit Function action to complete when the thread exits

cluster-worker

This is an object passed to the cluster worker. A cluster worker should be structured:

module.exports=(worker)=>{};

new virtuosity.multiThreading.cluster-worker();


Methods

cluster

creates a cluster of threads

virtuosity.multiThreading.cluster(path, input, onComplete, threads);


Parameter Type Description
path String path to the file to run in the thread
input Map data to send to the threads. The key of the map cooresponds to the thread
onComplete Function action to complete when the thread exits (takes output of the cluster as a parameter)
threads Int [Optional, default is number of CPU cores the computer has] Number of threads for the cluster to create