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(); }
public bool Add(TItem item, TimeSpan howLongAgo) { var performanceTimerTicks = PerformanceTimer.TimeNow - PerformanceTimer.SecondsToTicks(howLongAgo.TotalSeconds); return(Add(item, performanceTimerTicks)); }
public bool Add(TItem item, DateTime whenUtc) { var performanceTimerTicks = PerformanceTimer.TimeNow - PerformanceTimer.SecondsToTicks((DateTime.UtcNow - whenUtc).TotalSeconds); return(Add(item, performanceTimerTicks)); }