A* Pathfinding Project
4.1.19
The A* Pathfinding Project for Unity 3D
|
Helper for parallelizing tasks. More...
Helper for parallelizing tasks.
More specifically this class is useful if the tasks need some large and slow to initialize 'scratch pad'. Using this class you can initialize a scratch pad per thread and then use the appropriate one in the task callback (which includes a thread index).
Any exception that is thrown in the worker threads will be propagated out to the caller of the Run method.
Public Member Functions | |
ParallelWorkQueue (Queue< T > queue) | |
IEnumerable< int > | Run (int progressTimeoutMillis) |
Execute the tasks. More... | |
Public Attributes | |
System.Action< T, int > | action |
Callback to run for each item in the queue. More... | |
readonly int | threadCount |
Number of threads to use. More... | |
Private Member Functions | |
void | RunTask (int threadIndex) |
Private Attributes | |
readonly int | initialCount |
System.Exception | innerException |
readonly Queue< T > | queue |
Queue of items. More... | |
ManualResetEvent [] | waitEvents |
ParallelWorkQueue | ( | Queue< T > | queue | ) |
IEnumerable<int> Run | ( | int | progressTimeoutMillis | ) |
Execute the tasks.
progressTimeoutMillis | This iterator will yield approximately every progressTimeoutMillis milliseconds. This can be used to e.g show a progress bar. |
|
private |
System.Action<T, int> action |
Callback to run for each item in the queue.
The callback takes the item as the first parameter and the thread index as the second parameter.
|
private |
|
private |
|
private |
Queue of items.
readonly int threadCount |
Number of threads to use.
|
private |