Ejemplo n.º 1
0
 protected static CountConfig GetCachedObject(CountConfig config)
 {
     try
     {
         CountConfig.syncObject.EnterUpgradeableReadLock();
         CountConfig result;
         if (CountConfig.ExistingConfig.TryGetValue(config, out result))
         {
             return(result);
         }
         try
         {
             CountConfig.syncObject.EnterWriteLock();
             CountConfig.ExistingConfig.Add(config, config);
         }
         finally
         {
             if (CountConfig.syncObject.IsWriteLockHeld)
             {
                 CountConfig.syncObject.ExitWriteLock();
             }
         }
     }
     finally
     {
         if (CountConfig.syncObject.IsUpgradeableReadLockHeld)
         {
             CountConfig.syncObject.ExitUpgradeableReadLock();
         }
     }
     return(config);
 }
Ejemplo n.º 2
0
        internal void TimedUpdate()
        {
            DateTime dateTime = this.timeProvider();

            if (dateTime - this.lastUnpromotedEmptiedTime > this.config.PromotionInterval)
            {
                this.unpromotedMeasures.Clear();
                this.lastUnpromotedEmptiedTime = dateTime;
            }
            CountConfig.CleanupCachedConfig(dateTime, this.config.IdleCachedConfigCleanupInterval);
            foreach (CountTracker <TEntityType, TCountType> .EntityValue entityValue in this.entities.Values)
            {
                entityValue.TimedUpdate();
            }
            this.RemoveEmptyEntities(dateTime);
            if (this.needsEntityCleanup)
            {
                this.RemoveExcessEntitiesPerGroup(dateTime);
                this.RemoveExcessEntities(dateTime);
                this.needsEntityCleanup = false;
            }
        }
Ejemplo n.º 3
0
        public static RollingCountConfig Create(bool promotable, int minActivityThreshold, TimeSpan timeToLive, TimeSpan idleTimeToLive, bool removable, TimeSpan idleCleanupInterval, TimeSpan windowInterval, TimeSpan windowBucketSize, Func <DateTime> timeProvider)
        {
            RollingCountConfig config = new RollingCountConfig(promotable, minActivityThreshold, timeToLive, idleTimeToLive, removable, windowInterval, windowBucketSize, idleCleanupInterval, timeProvider);

            return((RollingCountConfig)CountConfig.GetCachedObject(config));
        }
Ejemplo n.º 4
0
 public bool Equals(CountConfig config)
 {
     return(!object.ReferenceEquals(null, config) && (object.ReferenceEquals(this, config) || (this.isPromotable.Equals(config.isPromotable) && this.minActivityThreshold == config.minActivityThreshold && this.timeToLive.Equals(config.timeToLive) && this.idleTimeToLive.Equals(config.idleTimeToLive) && this.isRemovable.Equals(config.isRemovable) && this.idleCleanupInterval.Equals(config.idleCleanupInterval))));
 }
Ejemplo n.º 5
0
        public static AbsoluteCountConfig Create(bool promotable, int minActivityThreshold, TimeSpan timeToLive, TimeSpan idleTimeToLive, bool removable, TimeSpan idleCleanupInterval, TimeSpan historyLookbackWindow, Func <DateTime> timeProvider)
        {
            AbsoluteCountConfig config = new AbsoluteCountConfig(promotable, minActivityThreshold, timeToLive, idleTimeToLive, removable, idleCleanupInterval, historyLookbackWindow, timeProvider);

            return((AbsoluteCountConfig)CountConfig.GetCachedObject(config));
        }