WorkerPool Class

Module: BinaryUtils

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: , data: }

The worker should respond with a message using the same structure.

Item Index

Attributes

Methods

createWorkers

()

Create workers for this pool.

runTask

(
  • data
  • callback
)

Create task to be executed in this pool.

Parameters:

  • data Object

    Data to be sent to the worker.

  • callback Function

    Function to be called by the worker after processing the data sent.

Attributes

file

String

Javascript file for the workers.

next

Number

Worker index to be used for the next task.

size

Number

Size of this worker pool.

tasks

Array

Tasks waiting to be processed.

workers

Array

List of worker of this pool.