public SummaryChild(Summary parent) { this.parentName = parent.Name; this.objectives = parent.objectives; this.maxAge = parent.maxAge; this.ageBuckets = parent.ageBuckets; this.bufCap = parent.bufCap; this.sortedObjectives = new double[this.objectives.Count]; this.hotBuf = new SampleBuffer(this.bufCap); this.coldBuf = new SampleBuffer(this.bufCap); this.streamDuration = new TimeSpan(this.maxAge.Ticks / this.ageBuckets); this.headStreamExpTime = DateTime.UtcNow.Add(this.streamDuration); this.hotBufExpTime = this.headStreamExpTime; this.streams = new QuantileStream[this.ageBuckets]; for (var i = 0; i < this.ageBuckets; i++) { this.streams[i] = QuantileStream.NewTargeted(this.objectives); } this.headStream = this.streams[0]; for (var i = 0; i < this.objectives.Count; i++) { this.sortedObjectives[i] = this.objectives[i].Quantile; } Array.Sort(this.sortedObjectives); }
// MaybeRotateStreams needs mtx AND bufMtx locked. private void MaybeRotateStreams() { while (!this.hotBufExpTime.Equals(this.headStreamExpTime)) { this.headStream.Reset(); this.headStreamIdx++; if (this.headStreamIdx >= this.streams.Length) { this.headStreamIdx = 0; } this.headStream = this.streams[this.headStreamIdx]; this.headStreamExpTime = this.headStreamExpTime.Add(this.streamDuration); } }