Exemple #1
0
        public AmbientBottleneckAccessor EnterBottleneck(AmbientBottleneck bottleneck)
        {
            AmbientBottleneckAccessor access = new AmbientBottleneckAccessor(this, bottleneck, AmbientClock.Ticks);

            foreach (IAmbientBottleneckExitNotificationSink notificationSink in _notificationSinks)
            {
                IAmbientBottleneckEnterNotificationSink?enterSink = notificationSink as IAmbientBottleneckEnterNotificationSink;
                enterSink?.BottleneckEntered(access);
            }
            return(access);
        }
 /// <summary>
 /// Constructs a AmbientBottleneckAccessRecord from the specified property values.
 /// </summary>
 /// <param name="owner">The <see cref="BasicAmbientBottleneckDetector"/> that owns this access.</param>
 /// <param name="bottleneck">The <see cref="AmbientBottleneck"/> being accessed.</param>
 /// <param name="accessBegin">The <see cref="DateTime"/> indicating the beginning of the access (presumably now, or just a bit ago).  Note that <see cref="DateTime"/> may not have the resolution of stopwatch ticks, so the start time may be slightly truncated as a result of the conversion.</param>
 internal AmbientBottleneckAccessor(BasicAmbientBottleneckDetector owner, AmbientBottleneck bottleneck, DateTime accessBegin)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
     if (bottleneck == null)
     {
         throw new ArgumentNullException(nameof(bottleneck));
     }
     _owner      = owner;
     _bottleneck = bottleneck;
     _accessBeginStopwatchTimestamp = TimeSpanExtensions.DateTimeToStopwatchTimestamp(accessBegin.Ticks);
     _accessEndStopwatchTimestamp   = long.MaxValue;
 }
 /// <summary>
 /// Constructs a single-access AmbientBottleneckAccessRecord for the specified bottleneck with access starting at the specified timestamp.
 /// </summary>
 internal AmbientBottleneckAccessor(BasicAmbientBottleneckDetector owner, AmbientBottleneck bottleneck, long accessBeginStopwatchTimestamp)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
     if (bottleneck == null)
     {
         throw new ArgumentNullException(nameof(bottleneck));
     }
     _owner      = owner;
     _bottleneck = bottleneck;
     _accessBeginStopwatchTimestamp = accessBeginStopwatchTimestamp;
     _accessEndStopwatchTimestamp   = long.MaxValue;
 }
 /// <summary>
 /// Constructs an AmbientBottleneckAccessRecord from the completely specified property values.
 /// </summary>
 internal AmbientBottleneckAccessor(BasicAmbientBottleneckDetector owner, AmbientBottleneck bottleneck, long accessBeginStopwatchTimestamp, long accessEndStopwatchTimestamp, long accessCount, double limitUsed)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
     if (bottleneck == null)
     {
         throw new ArgumentNullException(nameof(bottleneck));
     }
     _owner      = owner;
     _bottleneck = bottleneck;
     _accessBeginStopwatchTimestamp = accessBeginStopwatchTimestamp;
     _accessEndStopwatchTimestamp   = accessEndStopwatchTimestamp;
     _accessCount = accessCount;
     _limitUsed   = limitUsed;
     UpdateUtilization();
 }