コード例 #1
0
            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);
            }
コード例 #2
0
            // SwapBufs needs mtx AND bufMtx locked, coldBuf must be empty.
            private void SwapBufs(DateTime now)
            {
                if (!this.coldBuf.IsEmpty)
                {
                    throw new InvalidOperationException("coldBuf is not empty");
                }

                var temp = this.hotBuf;

                this.hotBuf  = this.coldBuf;
                this.coldBuf = temp;

                // hotBuf is now empty and gets new expiration set.
                while (now > this.hotBufExpTime)
                {
                    this.hotBufExpTime = this.hotBufExpTime.Add(this.streamDuration);
                }
            }