A* Pathfinding Project  4.3.2
The A* Pathfinding Project for Unity 3D
GraphUpdateProcessor Class Reference

Classes

struct  GUOSingle
 Holds a single update that needs to be performed on a graph. More...
 

Public Member Functions

 GraphUpdateProcessor (AstarPath astar)
 
void AddToQueue (GraphUpdateObject ob)
 Update all graphs using the GraphUpdateObject. More...
 
void DisableMultithreading ()
 
void EnableMultithreading ()
 
AstarWorkItem GetWorkItem ()
 Work item which can be used to apply all queued updates. More...
 

Properties

bool IsAnyGraphUpdateInProgress [get]
 Returns if any graph updates are in progress. More...
 
bool IsAnyGraphUpdateQueued [get]
 Returns if any graph updates are waiting to be applied. More...
 

Events

System.Action OnGraphsUpdated
 

Private Types

enum  GraphUpdateOrder { GraphUpdate }
 Order type for updating graphs. More...
 

Private Member Functions

bool ProcessGraphUpdates (bool force)
 Updates graphs. More...
 
void ProcessGraphUpdatesAsync ()
 Graph update thread. More...
 
void ProcessPostUpdates ()
 
bool ProcessRegularUpdates (bool force)
 
void QueueGraphUpdatesInternal ()
 Schedules graph updates internally. More...
 
bool StartAsyncUpdatesIfQueued ()
 Signal the graph update thread to start processing graph updates if there are any in the graphUpdateQueueAsync queue. More...
 

Private Attributes

bool anyGraphUpdateInProgress
 Used for IsAnyGraphUpdateInProgress. More...
 
readonly AstarPath astar
 Holds graphs that can be updated. More...
 
readonly System.Threading.ManualResetEvent asyncGraphUpdatesComplete = new System.Threading.ManualResetEvent(true)
 
readonly System.Threading.AutoResetEvent exitAsyncThread = new System.Threading.AutoResetEvent(false)
 
readonly System.Threading.AutoResetEvent graphUpdateAsyncEvent = new System.Threading.AutoResetEvent(false)
 
readonly Queue< GraphUpdateObjectgraphUpdateQueue = new Queue<GraphUpdateObject>()
 Queue containing all waiting graph update queries. More...
 
readonly Queue< GUOSinglegraphUpdateQueueAsync = new Queue<GUOSingle>()
 Queue of all async graph updates waiting to be executed. More...
 
readonly Queue< GUOSinglegraphUpdateQueuePost = new Queue<GUOSingle>()
 Queue of all non-async graph update post events waiting to be executed. More...
 
readonly Queue< GUOSinglegraphUpdateQueueRegular = new Queue<GUOSingle>()
 Queue of all non-async graph updates waiting to be executed. More...
 
Thread graphUpdateThread
 Reference to the thread which handles async graph updates. More...
 

Member Enumeration Documentation

◆ GraphUpdateOrder

enum GraphUpdateOrder
strongprivate

Order type for updating graphs.

Enumerator
GraphUpdate 

Constructor & Destructor Documentation

◆ GraphUpdateProcessor()

Member Function Documentation

◆ AddToQueue()

void AddToQueue ( GraphUpdateObject  ob)

Update all graphs using the GraphUpdateObject.

This can be used to, e.g make all nodes in an area unwalkable, or set them to a higher penalty. The graphs will be updated as soon as possible (with respect to AstarPath.batchGraphUpdates)

See also
FlushGraphUpdates

◆ DisableMultithreading()

void DisableMultithreading ( )

◆ EnableMultithreading()

void EnableMultithreading ( )

◆ GetWorkItem()

AstarWorkItem GetWorkItem ( )

Work item which can be used to apply all queued updates.

◆ ProcessGraphUpdates()

bool ProcessGraphUpdates ( bool  force)
private

Updates graphs.

Will do some graph updates, possibly signal another thread to do them. Will only process graph updates added by QueueGraphUpdatesInternal

Parameters
forceIf true, all graph updates will be processed before this function returns. The return value will be True.
Returns
True if all graph updates have been done and pathfinding (or other tasks) may resume. False if there are still graph updates being processed or waiting in the queue.

◆ ProcessGraphUpdatesAsync()

void ProcessGraphUpdatesAsync ( )
private

Graph update thread.

Async graph updates will be executed by this method in another thread.

◆ ProcessPostUpdates()

void ProcessPostUpdates ( )
private

◆ ProcessRegularUpdates()

bool ProcessRegularUpdates ( bool  force)
private

◆ QueueGraphUpdatesInternal()

void QueueGraphUpdatesInternal ( )
private

Schedules graph updates internally.

◆ StartAsyncUpdatesIfQueued()

bool StartAsyncUpdatesIfQueued ( )
private

Signal the graph update thread to start processing graph updates if there are any in the graphUpdateQueueAsync queue.

Returns
True if the other thread was signaled.

Member Data Documentation

◆ anyGraphUpdateInProgress

bool anyGraphUpdateInProgress
private

Used for IsAnyGraphUpdateInProgress.

◆ astar

readonly AstarPath astar
private

Holds graphs that can be updated.

◆ asyncGraphUpdatesComplete

readonly System.Threading.ManualResetEvent asyncGraphUpdatesComplete = new System.Threading.ManualResetEvent(true)
private

◆ exitAsyncThread

readonly System.Threading.AutoResetEvent exitAsyncThread = new System.Threading.AutoResetEvent(false)
private

◆ graphUpdateAsyncEvent

readonly System.Threading.AutoResetEvent graphUpdateAsyncEvent = new System.Threading.AutoResetEvent(false)
private

◆ graphUpdateQueue

readonly Queue<GraphUpdateObject> graphUpdateQueue = new Queue<GraphUpdateObject>()
private

Queue containing all waiting graph update queries.

Add to this queue by using AddToQueue.

See also
AddToQueue

◆ graphUpdateQueueAsync

readonly Queue<GUOSingle> graphUpdateQueueAsync = new Queue<GUOSingle>()
private

Queue of all async graph updates waiting to be executed.

◆ graphUpdateQueuePost

readonly Queue<GUOSingle> graphUpdateQueuePost = new Queue<GUOSingle>()
private

Queue of all non-async graph update post events waiting to be executed.

◆ graphUpdateQueueRegular

readonly Queue<GUOSingle> graphUpdateQueueRegular = new Queue<GUOSingle>()
private

Queue of all non-async graph updates waiting to be executed.

◆ graphUpdateThread

Thread graphUpdateThread
private

Reference to the thread which handles async graph updates.

See also
ProcessGraphUpdatesAsync

Property Documentation

◆ IsAnyGraphUpdateInProgress

bool IsAnyGraphUpdateInProgress
get

Returns if any graph updates are in progress.

◆ IsAnyGraphUpdateQueued

bool IsAnyGraphUpdateQueued
get

Returns if any graph updates are waiting to be applied.

Event Documentation

◆ OnGraphsUpdated

System.Action OnGraphsUpdated

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