A* Pathfinding Project  4.1.7
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 flood fill 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 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...
 

Private Attributes

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 flood fill 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.

Member Data Documentation

◆ 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

◆ 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: