new ThreadPool(poolSize)
- Source:
Thread Pool. Highly inspired from http://www.smartjava.org/content/html5-easily-parallelize-jobs-using-web-workers-and-threadpool.
Parameters:
Name | Type | Description |
---|---|---|
poolSize |
number | The size of the pool. |
Methods
abort()
- Source:
Abort all threads.
addWorkerTask(workerTask)
- Source:
Add a worker task to the queue. Will be run when a thread is made available.
Parameters:
Name | Type | Description |
---|---|---|
workerTask |
object | The task to add to the queue. |
handleWorkerError(event)
- Source:
Handle an error message from a worker.
Parameters:
Name | Type | Description |
---|---|---|
event |
object | The error event. |
onabort(_event)
- Source:
Handle an abort event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The abort event. |
onerror(_event)
- Source:
Handle an error event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The error event. |
onTaskEnd(workerThread)
- Source:
Handle a task end.
Parameters:
Name | Type | Description |
---|---|---|
workerThread |
object | The thread to free. |
onwork(_event)
- Source:
Handle a work event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The work event fired when a work ended successfully. |
onworkend(_event)
- Source:
Handle a work end event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The work end event fired when a work has completed, successfully or not. |
onworkitem(_event)
- Source:
Handle a work item event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The work item event fired when a work item ended successfully. |
onworkstart(_event)
- Source:
Handle a work start event. Default does nothing.
Parameters:
Name | Type | Description |
---|---|---|
_event |
object | The work start event. |