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

Classes

class  IndexedQueue
 Similar to Queue<T> but allows random access. More...
 

Public Member Functions

 WorkItemProcessor (AstarPath astar)
 
void AddWorkItem (AstarWorkItem item)
 Add a work item to be processed when pathfinding is paused. More...
 
void EnsureValidFloodFill ()
 If a WorkItem needs to have a valid area information during execution, call this method to ensure there are no pending flood fills. More...
 
void OnFloodFill ()
 
bool ProcessWorkItems (bool force)
 Process graph updating work items. More...
 

Properties

bool anyQueued [get]
 True if any work items are queued right now. More...
 
bool workItemsInProgress [get, private set]
 True while a batch of work items are being processed. More...
 
bool workItemsInProgressRightNow [get, private set]
 Used to prevent waiting for work items to complete inside other work items as that will cause the program to hang. More...
 

Private Member Functions

void IWorkItemContext. QueueFloodFill ()
 Call during work items to queue a flood fill. More...
 
void IWorkItemContext. SetGraphDirty (NavGraph graph)
 Trigger a graph modification event. More...
 

Private Attributes

bool anyGraphsDirty = true
 
readonly AstarPath astar
 
bool queuedWorkItemFloodFill = false
 True if any work items have queued a flood fill. More...
 
readonly IndexedQueue< AstarWorkItemworkItems = new IndexedQueue<AstarWorkItem>()
 

Constructor & Destructor Documentation

◆ WorkItemProcessor()

Member Function Documentation

◆ AddWorkItem()

void AddWorkItem ( AstarWorkItem  item)

Add a work item to be processed when pathfinding is paused.

See also
ProcessWorkItems

◆ EnsureValidFloodFill()

void EnsureValidFloodFill ( )

If a WorkItem needs to have a valid area information during execution, call this method to ensure there are no pending flood fills.

Implements IWorkItemContext.

◆ OnFloodFill()

void OnFloodFill ( )

◆ ProcessWorkItems()

bool ProcessWorkItems ( bool  force)

Process graph updating work items.

Process all queued work items, e.g graph updates and the likes.

Returns
  • false if there are still items to be processed.
  • true if the last work items was processed and pathfinding threads are ready to be resumed.
See also
AddWorkItem
threadSafeUpdateState
Update

◆ QueueFloodFill()

void IWorkItemContext. QueueFloodFill ( )
private

Call during work items to queue a flood fill.

An instant flood fill can be done via FloodFill() but this method can be used to batch several updates into one to increase performance. WorkItems which require a valid Flood Fill in their execution can call EnsureValidFloodFill to ensure that a flood fill is done if any earlier work items queued one.

Once a flood fill is queued it will be done after all WorkItems have been executed.

Implements IWorkItemContext.

◆ SetGraphDirty()

void IWorkItemContext. SetGraphDirty ( NavGraph  graph)
private

Trigger a graph modification event.

This will cause a #Pathfinding.GraphModifier.PostUpdate event to be issued after all graph updates have finished. Some scripts listen for this event. For example off-mesh links listen to it and will recalculate which nodes they are connected to when it it sent. If a graph is dirtied multiple times, or even if multiple graphs are dirtied, the event will only be sent once.

Implements IWorkItemContext.

Member Data Documentation

◆ anyGraphsDirty

bool anyGraphsDirty = true
private

◆ astar

readonly AstarPath astar
private

◆ queuedWorkItemFloodFill

bool queuedWorkItemFloodFill = false
private

True if any work items have queued a flood fill.

See also
QueueWorkItemFloodFill

◆ workItems

readonly IndexedQueue<AstarWorkItem> workItems = new IndexedQueue<AstarWorkItem>()
private

Property Documentation

◆ anyQueued

bool anyQueued
get

True if any work items are queued right now.

◆ workItemsInProgress

bool workItemsInProgress
getprivate set

True while a batch of work items are being processed.

Set to true when a work item is started to be processed, reset to false when all work items are complete.

Work item updates are often spread out over several frames, this flag will be true during the whole time the updates are in progress.

◆ workItemsInProgressRightNow

bool workItemsInProgressRightNow
getprivate set

Used to prevent waiting for work items to complete inside other work items as that will cause the program to hang.


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