A* Pathfinding Project
4.1.10
The A* Pathfinding Project for Unity 3D
|
Queue of paths to be processed by the system. More...
Queue of paths to be processed by the system.
Classes | |
class | QueueTerminationException |
Public Member Functions | |
ThreadControlQueue (int numReceivers) | |
Create a new queue with the specified number of receivers. More... | |
void | Block () |
Block queue, all calls to Pop will block until Unblock is called. More... | |
void | Lock () |
Aquires a lock on this queue. More... | |
Path | Pop () |
Pops the next item off the queue. More... | |
Path | PopNoBlock (bool blockedBefore) |
Pops the next item off the queue, this call will not block. More... | |
void | Push (Path path) |
Push a path to the end of the queue. More... | |
void | PushFront (Path path) |
Push a path to the front of the queue. More... | |
void | ReceiverTerminated () |
Call when a receiver was terminated in other ways than by a QueueTerminationException. More... | |
void | TerminateReceivers () |
All calls to Pop and PopNoBlock will now generate exceptions. More... | |
void | Unblock () |
Unblock queue. More... | |
void | Unlock () |
Releases the lock on this queue. More... | |
Properties | |
bool | AllReceiversBlocked [get] |
True if blocking and all receivers are waiting for unblocking. More... | |
bool | IsEmpty [get] |
True if the queue is empty. More... | |
bool | IsTerminating [get] |
True if TerminateReceivers has been called. More... | |
Private Member Functions | |
void | Starving () |
Private Attributes | |
ManualResetEvent | block = new ManualResetEvent(true) |
bool | blocked |
int | blockedReceivers |
Number of receiver threads that are currently blocked. More... | |
Path | head |
readonly System.Object | lockObj = new System.Object() |
readonly int | numReceivers |
bool | starving |
True while head == null. More... | |
Path | tail |
bool | terminate |
True after TerminateReceivers has been called. More... | |
ThreadControlQueue | ( | int | numReceivers | ) |
Create a new queue with the specified number of receivers.
It is important that the number of receivers is fixed. Properties like AllReceiversBlocked rely on knowing the exact number of receivers using the Pop (or PopNoBlock) methods.
void Block | ( | ) |
Block queue, all calls to Pop will block until Unblock is called.
void Lock | ( | ) |
Aquires a lock on this queue.
Must be paired with a call to Unlock
Path Pop | ( | ) |
Pops the next item off the queue.
This call will block if there are no items in the queue or if the queue is currently blocked.
QueueTerminationException | if TerminateReceivers has been called. |
System.InvalidOperationException | if more receivers get blocked than the fixed count sent to the constructor |
Path PopNoBlock | ( | bool | blockedBefore | ) |
Pops the next item off the queue, this call will not block.
To ensure stability, the caller must follow this pattern. 1. Call PopNoBlock(false), if a null value is returned, wait for a bit (e.g yield return null in a Unity coroutine) 2. try again with PopNoBlock(true), if still null, wait for a bit 3. Repeat from step 2.
QueueTerminationException | if TerminateReceivers has been called. |
System.InvalidOperationException | if more receivers get blocked than the fixed count sent to the constructor |
void Push | ( | Path | path | ) |
Push a path to the end of the queue.
void PushFront | ( | Path | path | ) |
Push a path to the front of the queue.
void ReceiverTerminated | ( | ) |
Call when a receiver was terminated in other ways than by a QueueTerminationException.
After this call, the receiver should be dead and not call anything else in this class.
|
private |
void TerminateReceivers | ( | ) |
All calls to Pop and PopNoBlock will now generate exceptions.
void Unblock | ( | ) |
void Unlock | ( | ) |
Releases the lock on this queue.
|
private |
|
private |
|
private |
Number of receiver threads that are currently blocked.
This is only modified while a thread has a lock on lockObj
|
private |
|
private |
|
private |
|
private |
True while head == null.
This is only modified while a thread has a lock on lockObj
|
private |
|
private |
True after TerminateReceivers has been called.
All receivers will be terminated when they next call Pop.
|
get |
True if blocking and all receivers are waiting for unblocking.
|
get |
True if the queue is empty.
|
get |
True if TerminateReceivers has been called.