Class: WorkerWrapper

pool~WorkerWrapper(worker)

Wrapper for a worker that can submit jobs to the worker and receive responses.

Constructor

new WorkerWrapper(worker)

Parameters:
Name Type Description
worker Worker

the worker to wrap

Source:

Methods

getJobCount() → {Number}

Get the number of jobs currently running

Source:
Returns:

the number of jobs currently running

Type
Number

newJobId() → {Number}

Get a new job id

Source:
Returns:

the new job id

Type
Number

submitJob(message, transferablesopt) → {Promise}

Submit a job to the worker

Parameters:
Name Type Attributes Description
message Object

the message to send to the worker. A "jobId" property will be added to this object.

transferables Array.<Object> <optional>

an optional array of transferable objects to transfer to the worker.

Source:
Returns:

a promise that gets resolved/rejected when a message with the same jobId is received from the worker.

Type
Promise