Class AutoReleaseWorkerPool
Hierarchy (View Summary)
- WorkerPool
- AutoReleaseWorkerPool
Index
Constructors
constructor
-
new AutoReleaseWorkerPool(
maxWorkers: number,
createWorkerAsync: () => Promise<Worker>,
options?: AutoReleaseWorkerPoolOptions,
): AutoReleaseWorkerPoolParameters
- maxWorkers: number
- createWorkerAsync: () => Promise<Worker>
- options: AutoReleaseWorkerPoolOptions = AutoReleaseWorkerPool.DefaultOptions
Returns AutoReleaseWorkerPool
Properties
StaticDefault Options
Default options for the constructor. Override to change the defaults.
Methods
dispose
-
Terminates all workers and clears any pending actions.
Returns void
push
-
Pushes an action to the worker pool. If all the workers are active, the action will be pended until a worker has completed its action.
Parameters
- action: (worker: Worker, onComplete: () => void) => void
The action to perform. Call onComplete when the action is complete.
Returns void
- action: (worker: Worker, onComplete: () => void) => void
Similar to the WorkerPool class except it creates and destroys workers automatically with a maximum of
maxWorkersworkers. Workers are terminated when it is idle for at leastidleTimeElapsedBeforeReleasemilliseconds.