A* Pathfinding Project  4.1.5
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
ParallelWorkQueue< T > Class Template Reference

Helper for parallelizing tasks. More...

Detailed Description

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.
 

Public Attributes

System.Action< T, int > action
 Callback to run for each item in the queue.
 
readonly int threadCount
 Number of threads to use.
 

Private Member Functions

void RunTask (int threadIndex)
 

Private Attributes

readonly int initialCount
 
System.Exception innerException
 
readonly Queue< T > queue
 Queue of items.
 
ManualResetEvent[] waitEvents
 

Constructor & Destructor Documentation

ParallelWorkQueue ( Queue< T >  queue)

Member Function Documentation

IEnumerable<int> Run ( int  progressTimeoutMillis)

Execute the tasks.

Parameters
progressTimeoutMillisThis iterator will yield approximately every progressTimeoutMillis milliseconds. This can be used to e.g show a progress bar.
void RunTask ( int  threadIndex)
private

Member Data Documentation

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.

readonly int initialCount
private
System.Exception innerException
private
readonly Queue<T> queue
private

Queue of items.

readonly int threadCount

Number of threads to use.

ManualResetEvent [] waitEvents
private

The documentation for this class was generated from the following file: