protected override void MarkInternalWindowStart() { if (_lastState != null) { throw new IOException( "_lastState not equels to null when trying to set start of intervalWindow"); } _lastState = new InternalWindowDuration { Start = DateTime.UtcNow }; }
protected override void MarkInternalWindowEnd() { if (_lastState == null) { throw new IOException("_lastState equels to null when trying to set end of intervalWindow!"); // TODO : do not throw.. just log and ignore } _lastState.End = DateTime.UtcNow; if (Math.Abs(Math.Round((_lastState.End - _lastState.Start).TotalMilliseconds, 2)) < double.Epsilon) { _lastState = null; return; } _lastState.Prev = _tail; _tail = _lastState; _lastState = null; }
protected override void Mark(long counter, long commandsCounter, DateTime start, DateTime end) { var meterItem = new TransactionMeterItem() { Start = start, Counter = counter, CommandsCounter = commandsCounter, End = end, InternalDurations = _tail }; _tail = null; var pos = Interlocked.Increment(ref BufferPos); var adjustedTail = pos % Buffer.Length; if (Interlocked.CompareExchange(ref Buffer[adjustedTail], meterItem, null) == null) { return; } StoreInSummarizeItem(meterItem, adjustedTail); }