Пример #1
0
 /// <summary>
 /// When the precondition for a chunk to be in this stage fails,
 /// if the chunk is in this stage, send it back.
 /// </summary>
 /// <param name="chunkId"></param>
 private void OnPreconditionFailure(Vector3Int chunkId)
 {
     if (queue.TryRemove(chunkId))
     {
         GoingBackwardsThisUpdate.Add(chunkId);
     }
 }
Пример #2
0
        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();
        }