Esempio n. 1
0
        //frame update

        public void SavePredictionCompoments(int seqHistoryId)
        {
            EntityMap localEntites = provider.LocalEntityMap;

#pragma warning disable RefCounter001,RefCounter002
            EntityMap remoteEntities = PredictionEntityMap.Allocate();
#pragma warning restore RefCounter001,RefCounter002
            EntityMapDeepCloner.Clone(remoteEntities, localEntites, CloneFilter.Instance);

            HistoryEntityMap historyEntityMap = GetTargetHistory(seqHistoryId);
            if (historyEntityMap == null)
            {
                logger.DebugFormat("SavePredictionCompoments1  {0}", seqHistoryId);
                historyEntityMap = new HistoryEntityMap(seqHistoryId, remoteEntities);
                histories.Enqueue(historyEntityMap);
            }
            else
            {
                logger.DebugFormat("Recplce SavePredictionCompoments  {0}", seqHistoryId);
                RefCounterRecycler.Instance.ReleaseReference(historyEntityMap.EntityMap);
                historyEntityMap.EntityMap = remoteEntities;
            }

            if (histories.Count > MaxHistory)
            {
                var tdhistory = histories.Dequeue();
                RefCounterRecycler.Instance.ReleaseReference(tdhistory.EntityMap);
            }
        }
Esempio n. 2
0
        public void SavePredictionCompoments(int historyId)
        {
            EntityMap localEntites = _handler.LocalEntityMap;

#pragma warning disable RefCounter001,RefCounter002
            EntityMap remoteEntities = PredictionEntityMap.Allocate();
#pragma warning restore RefCounter001,RefCounter002
            EntityMapDeepCloner.Clone(remoteEntities, localEntites, _filter);

            SavedHistory history = GetTargetHistory(historyId);
            if (history == null)
            {
                _logger.DebugFormat("SavePredictionCompoments_1  {0}", historyId);
                history = new SavedHistory(historyId, remoteEntities);
                _histories.Add(history);
            }
            else
            {
                _logger.DebugFormat("Recplce SavePredictionCompoments  {0}", historyId);
                RefCounterRecycler.Instance.ReleaseReference(history.EntityMap);
                history.EntityMap = remoteEntities;
            }
            if (_histories.Count > MaxHistory)
            {
                var tdhistory = _histories[0];
                RefCounterRecycler.Instance.ReleaseReference(tdhistory.EntityMap);
                _histories.RemoveAt(0);
            }
        }