/// <summary> /// Clear the output lists in preparation for next update /// </summary> public void ClearLists() { MovingOnThisUpdate.Clear(); //TerminatingThisUpdate.Clear(); GoingBackwardsThisUpdate.Clear(); listsCleared = true; }
public override void Update() { base.Update(); foreach (var pair in jobs) { var chunkId = pair.Key; var job = pair.Value; if (job.Done) { if (CheckAndResolvePreconditionsBeforeExit(chunkId)) { MovingOnThisUpdate.Add(chunkId); Profiler.BeginSample("OnJobDone"); OnJobDone(chunkId, job.Result); Profiler.EndSample(); //Remove this id from the stage, as it's moving on removalHelper.Add(chunkId); } } } foreach (var item in removalHelper) { jobs.Remove(item); } removalHelper.Clear(); }
public override void Update() { base.Update(); foreach (var item in waitEndedSet) { if (neighbourStatuses.TryGetValue(item, out var status)) { if (status.AllValid) { if (CheckAndResolvePreconditionsBeforeExit(item)) { MovingOnThisUpdate.Add(item); neighbourStatuses.Remove(item); OnWaitEnded(item); } } else { ///Status changed since it was added to the waitEndedSet, ///it cannot be moved on yet. } } } waitEndedSet.Clear(); }
public override void Update() { base.Update(); //Get next stage's entry limit int maxToMoveOn = pipeline.GetStage(StageID + 1).EntryLimit; int movedOn = 0; //Iterate over queue in order, until at most maxToMoveOn items have been moved on foreach (var item in queue) { if (movedOn >= maxToMoveOn) { break; } if (pipeline.NextStageFreeForChunk(item, StageID)) { //Just before the chunk would move on, re-check that the preconditions still hold if (CheckAndResolvePreconditionsBeforeExit(item)) { MovingOnThisUpdate.Add(item); movedOn++; } } else { //Otherwise, the chunk neither moves on nor terminates, it waits continue; } } //Remove items from the queue when they move on foreach (var item in MovingOnThisUpdate) { queue.Remove(item); } //Remove items from the queue when they terminate foreach (var item in terminatingThisUpdateHelper) { queue.Remove(item); } ///Items in the going backwards list have already been removed from the queue, ///but we need to make sure they should really be going backwards, not just terminating GoingBackwardsThisUpdate.RemoveWhere((id) => TerminateHereCondition(id)); //Clear the terminating helper list terminatingThisUpdateHelper.Clear(); }