Exemplo n.º 1
0
        public HistoryBucketQueue(
            TimeSpan depth,
            int bucketCount,
            Func <TBucket> createBucketAction,
            Action <TBucket, TItem> accumulateAction,
            Action <TBucket, long> clearAction)
        {
            _accumulateAction = accumulateAction;
            _clearAction      = clearAction;

            _buckets = new TBucket[bucketCount];
            for (var i = 0; i < bucketCount; i++)
            {
                _buckets[i] = createBucketAction();
            }

            _ticksPerBucket = PerformanceTimer.SecondsToTicks(depth.TotalSeconds / bucketCount);

            Clear();
        }
Exemplo n.º 2
0
        public bool Add(TItem item, TimeSpan howLongAgo)
        {
            var performanceTimerTicks = PerformanceTimer.TimeNow - PerformanceTimer.SecondsToTicks(howLongAgo.TotalSeconds);

            return(Add(item, performanceTimerTicks));
        }
Exemplo n.º 3
0
        public bool Add(TItem item, DateTime whenUtc)
        {
            var performanceTimerTicks = PerformanceTimer.TimeNow - PerformanceTimer.SecondsToTicks((DateTime.UtcNow - whenUtc).TotalSeconds);

            return(Add(item, performanceTimerTicks));
        }