ThreadPool
Extends:
Implements:
- Disposable ,
- EventListener
Manages worker threads.
Constructor Summary
Public Constructor | ||
public |
constructor(maxWorkers: Number) Constructs a new thread pool. |
Member Summary
Public Members | ||
public |
A configuration message. |
|
public |
The maximum number of active worker threads. |
Method Summary
Public Methods | ||
public |
clear() Resets this thread pool by closing all workers. |
|
public |
closeWorker(worker: Worker) Closes a worker. |
|
public |
dispose() Removes all active workers and releases the worker program blob. |
|
public |
getWorker(): Worker Polls an available worker and returns it. |
|
public |
handleEvent(event: Event) Handles events. |
Public Constructors
Public Members
public configurationMessage: ConfigurationMessage source
A configuration message.
This object will be sent to each newly created worker.
Public Methods
public closeWorker(worker: Worker) source
Closes a worker.
Params:
Name | Type | Attribute | Description |
worker | Worker | The worker to close. |
public getWorker(): Worker source
Polls an available worker and returns it. The worker will be excluded from subsequent polls until it finishes its task and sends a message back.
Return:
Worker | A worker or null if all resources are currently exhausted. |