public PopNoBlock ( bool blockedBefore ) : |
||
blockedBefore | bool | |
Résultat |
public Path PopNoBlock (bool blockedBefore) {
Monitor.Enter(lockObj);
try {
if (terminate) {
blockedReceivers++;
throw new QueueTerminationException();
}
if (head == null) {
Starving ();
}
if (blocked || starving) {
if (!blockedBefore) {
blockedReceivers++;
if (terminate) throw new QueueTerminationException();
if (blockedReceivers == numReceivers) {
//Last alive
} else if (blockedReceivers > numReceivers) {
throw new System.InvalidOperationException ("More receivers are blocked than specified in constructor ("+blockedReceivers + " > " + numReceivers+")");
}
}
return null;
} else if (blockedBefore) {
blockedReceivers--;
}
Path p = head;
if (head.next == null) {
tail = null;
}
head = head.next;
return p;
} finally {
Monitor.Exit (lockObj);
}
}
}
public void TickNonMultithreaded() { // Process paths if (threadCoroutine != null) { try { threadCoroutine.MoveNext(); } catch (System.Exception e) { //This will kill pathfinding threadCoroutine = null; // Queue termination exceptions should be ignored, they are supposed to kill the thread if (!(e is ThreadControlQueue.QueueTerminationException)) { Debug.LogException(e); Debug.LogError("Unhandled exception during pathfinding. Terminating."); queue.TerminateReceivers(); // This will throw an exception supposed to kill the thread try { queue.PopNoBlock(false); } catch {} } } } }