WorkerPool Class
Worker pool is used to manage and execute mutiple task of the same type using a predefined number of workers.
Workers are pre initialized to avoid the overhead of creation during execution.
These workers receive messages with a uuid of the task and the data to be processed.
{
uuid:
The worker should respond with a message using the same structure.
Methods
createWorkers
()
Create workers for this pool.
runTask
(
-
data
-
callback
Create task to be executed in this pool.
Parameters:
-
data
ObjectData to be sent to the worker.
-
callback
FunctionFunction to be called by the worker after processing the data sent.