ThreadPool
Source: thread.js:62
Thread Pool.
Highly inspired from http://www.smartjava.org/content/html5-easily-parallelize-jobs-using-web-workers-and-threadpool.
Constructor
new ThreadPool(poolSize?: number): ThreadPoolParameters
poolSize(number, optional) — The size of the pool, defaults to getDefaultPoolSize. Must be a positive integer, it is clamped to the number of logical processors if available.
Instance Methods
addWorkerTask(workerTask: WorkerTask)
Add a worker task to the queue. Will be run when a thread is made available.
Parameters
workerTask(WorkerTask) — The task to add to the queue.
abort()
Abort all threads.
onTaskEnd(workerThread: WorkerThread)
Handle a task end.
Parameters
workerThread(WorkerThread) — The thread to free.
onworkstart(_event: object)
Handle a work start event. Default does nothing.
Parameters
_event(object) — The work start event.
onworkitem(_event: object)
Handle a work item event. Default does nothing.
Parameters
_event(object) — The work item event fired when a work item ended successfully.
onwork(_event: object)
Handle a work event. Default does nothing.
Parameters
_event(object) — The work event fired when a work ended successfully.
onworkend(_event: object)
Handle a work end event. Default does nothing.
Parameters
_event(object) — The work end event fired when a work has completed, successfully or not.
onerror(_event: object)
Handle an error event. Default does nothing.
Parameters
_event(object) — The error event.
onabort(_event: object)
Handle an abort event. Default does nothing.
Parameters
_event(object) — The abort event.
Instance Fields
handleWorkerError
Handle an error message from a worker.
Parameters
event(object) — The error event.