Class: SharedWorkerPool
A pool of web workers that can be used to execute jobs. The pool will create workers up to the maximum number of workers specified in the options. When a job is queued, the pool will find the first available worker and execute the job. If no workers are available, the job will be queued until a worker becomes available.
Constructors
constructor
• new SharedWorkerPool(Proto, options?): SharedWorkerPool
Create a new worker pool.
Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
| Proto | () => SharedWorker | undefined | The worker class to create. | 
| options | SharedWorkerPoolOptions | defaultOptions | The options to create the worker pool. | 
Returns
Properties
Proto
• Proto: () => SharedWorker
The worker class to create.
Type declaration
• new Proto(): SharedWorker
Returns
SharedWorker
WORKING_COUNT
▪ Static WORKING_COUNT: number = 0
A static count of working web workers across all worker pools.
options
• options: SharedWorkerPoolOptions = defaultOptions
The options to create the worker pool.
queue
• queue: SharedWorkerPoolJob[] = []
The queue of jobs that are waiting to be executed.
Accessors
isBusy
• get isBusy(): boolean
Whether or not are there no available workers.
Returns
boolean
workingCount
• get workingCount(): number
The number of workers that are simultaneously working.
Returns
number
Methods
addJob
▸ addJob(job): void
Append a new job to be executed by a worker.
Parameters
| Name | Type | Description | 
|---|---|---|
| job | SharedWorkerPoolJob | The job to queue. | 
Returns
void