コード例 #1
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);
            }
        }
コード例 #2
0
        private bool IsHistoryDifferentFrom(EntityMap remoteEntityMap)
        {
            PredictionCompareHandler <TPredictionComponent> compareHandler = new PredictionCompareHandler <TPredictionComponent>(_handler.RemoteHistoryId);
            SavedHistory history = GetTargetHistory(_handler.RemoteHistoryId);

            if (history != null)
            {
                EntityMapComparator.Diff(history.EntityMap, remoteEntityMap, compareHandler, "predicteCompare");
                if (compareHandler.IsDiff)
                {
                    SingletonManager.Get <DurationHelp>().IncreaseRewindCount();
                    _logger.InfoFormat("should rewind for history diff, historyId {0} {1}", _handler.RemoteHistoryId, history.HistoryId);
                }
                return(compareHandler.IsDiff);
            }
            int oldestHistory = _histories.Count > 0 ? _histories[0].HistoryId : 0;
            int latestHistory = _histories.Count > 0 ? _histories[_histories.Count - 1].HistoryId : 0;

            _logger.InfoFormat("should rewind for history not saved, historyId {0}, saved history = {1}-{2}", _handler.RemoteHistoryId, oldestHistory, latestHistory);
            return(true);
        }