示例#1
0
 protected virtual void TriggerRelease(Event @event = null)
 {
     while (ReleaseQueue.Count > 0)
     {
         var release = ReleaseQueue.Peek();
         if (release.Request.IsAlive)
         {
             if (!RequestQueue.Remove(release.Request))
             {
                 throw new InvalidOperationException("Failed to cancel a request.");
             }
             BreakOffTime?.Add(Environment.ToDouble(Environment.Now - release.Request.Time));
             release.Succeed();
             ReleaseQueue.Dequeue();
         }
         else
         {
             DoRelease(release);
             if (release.IsTriggered)
             {
                 ReleaseQueue.Dequeue();
                 TriggerWhenAny();
                 TriggerWhenFull();
                 TriggerWhenChange();
             }
             else
             {
                 break;
             }
         }
     }
     Utilization?.UpdateTo(InUse / (double)Capacity);
     WIP?.UpdateTo(InUse + RequestQueue.Count);
     QueueLength?.UpdateTo(RequestQueue.Count);
 }
示例#2
0
        protected virtual void TriggerRequest(Event @event = null)
        {
            var current = RequestQueue.First;

            while (current != null)
            {
                var request = current.Value;
                DoRequest(request);
                if (request.IsTriggered)
                {
                    var next = current.Next;
                    RequestQueue.Remove(current);
                    current = next;
                    TriggerWhenEmpty();
                    TriggerWhenChange();
                }
                else
                {
                    current = current.Next;
                }
                if (Resources.Count == 0)
                {
                    break;
                }
            }
            Utilization?.UpdateTo(InUse / (double)Capacity);
            WIP?.UpdateTo(InUse + RequestQueue.Count);
            QueueLength?.UpdateTo(RequestQueue.Count);
        }
        /// <summary>
        /// Returns a name identifying the method.
        /// </summary>
        /// <returns>The name of the method.</returns>
        public override string GetMethodName()
        {
            if (!string.IsNullOrWhiteSpace(Name))
            {
                return(Name);
            }
            string name = "obQ";

            name += QueueLength.ToString(IOConstants.FORMATTER);
            return(name);
        }
        public void RegisterMetrics(MetricFactory metrics)
        {
            if (!_threadPoolInfo.Enabled && !_runtimeCounters.Enabled)
            {
                return;
            }

            NumThreads = metrics.CreateGauge("dotnet_threadpool_num_threads", "The number of active threads in the thread pool");
            _runtimeCounters.Events.ThreadPoolThreadCount += e => NumThreads.Set(e.Mean);

            Throughput = metrics.CreateCounter("dotnet_threadpool_throughput_total", "The total number of work items that have finished execution in the thread pool");
            _runtimeCounters.Events.ThreadPoolCompletedItemsCount += e => Throughput.Inc(e.IncrementedBy);

            QueueLength = metrics.CreateHistogram("dotnet_threadpool_queue_length",
                                                  "Measures the queue length of the thread pool. Values greater than 0 indicate a backlog of work for the threadpool to process.",
                                                  new HistogramConfiguration {
                Buckets = _options.QueueLengthHistogramBuckets
            }
                                                  );
            _runtimeCounters.Events.ThreadPoolQueueLength += e => QueueLength.Observe(e.Mean);

            NumTimers = metrics.CreateGauge("dotnet_threadpool_timer_count", "The number of timers active");
            _runtimeCounters.Events.ActiveTimerCount += e => NumTimers.Set(e.Mean);

            if (_threadPoolInfo.Enabled)
            {
                AdjustmentsTotal = metrics.CreateCounter(
                    "dotnet_threadpool_adjustments_total",
                    "The total number of changes made to the size of the thread pool, labeled by the reason for change",
                    "adjustment_reason");

                _threadPoolInfo.Events.ThreadPoolAdjusted += e =>
                {
                    AdjustmentsTotal.Labels(_adjustmentReasonToLabel[e.AdjustmentReason]).Inc();
                };

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // IO threadpool only exists on windows
                    NumIocThreads = metrics.CreateGauge("dotnet_threadpool_io_num_threads", "The number of active threads in the IO thread pool");
                    _threadPoolInfo.Events.IoThreadPoolAdjusted += e => NumIocThreads.Set(e.NumThreads);
                }
            }
        }
示例#5
0
 protected virtual void TriggerRequest(Event @event = null)
 {
     while (RequestQueue.Count > 0)
     {
         var request = RequestQueue.First.Value;
         DoRequest(request);
         if (request.IsTriggered)
         {
             RequestQueue.RemoveFirst();
             TriggerWhenEmpty();
             TriggerWhenChange();
         }
         else
         {
             break;
         }
     }
     Utilization?.UpdateTo(InUse / (double)Capacity);
     WIP?.UpdateTo(InUse + RequestQueue.Count);
     QueueLength?.UpdateTo(RequestQueue.Count);
 }
示例#6
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (StaticPlot != null)
                {
                    hashCode = hashCode * 59 + StaticPlot.GetHashCode();
                }

                if (PlotlyServerUrl != null)
                {
                    hashCode = hashCode * 59 + PlotlyServerUrl.GetHashCode();
                }

                if (Editable != null)
                {
                    hashCode = hashCode * 59 + Editable.GetHashCode();
                }

                if (Edits != null)
                {
                    hashCode = hashCode * 59 + Edits.GetHashCode();
                }

                if (AutoSizable != null)
                {
                    hashCode = hashCode * 59 + AutoSizable.GetHashCode();
                }

                if (Responsive != null)
                {
                    hashCode = hashCode * 59 + Responsive.GetHashCode();
                }

                if (FillFrame != null)
                {
                    hashCode = hashCode * 59 + FillFrame.GetHashCode();
                }

                if (FrameMargins != null)
                {
                    hashCode = hashCode * 59 + FrameMargins.GetHashCode();
                }

                if (ScrollZoom != null)
                {
                    hashCode = hashCode * 59 + ScrollZoom.GetHashCode();
                }

                if (DoubleClick != null)
                {
                    hashCode = hashCode * 59 + DoubleClick.GetHashCode();
                }

                if (DoubleClickDelay != null)
                {
                    hashCode = hashCode * 59 + DoubleClickDelay.GetHashCode();
                }

                if (ShowAxisDragHandles != null)
                {
                    hashCode = hashCode * 59 + ShowAxisDragHandles.GetHashCode();
                }

                if (ShowAxisRangeEntryBoxes != null)
                {
                    hashCode = hashCode * 59 + ShowAxisRangeEntryBoxes.GetHashCode();
                }

                if (ShowTips != null)
                {
                    hashCode = hashCode * 59 + ShowTips.GetHashCode();
                }

                if (ShowLink != null)
                {
                    hashCode = hashCode * 59 + ShowLink.GetHashCode();
                }

                if (LinkText != null)
                {
                    hashCode = hashCode * 59 + LinkText.GetHashCode();
                }

                if (SendData != null)
                {
                    hashCode = hashCode * 59 + SendData.GetHashCode();
                }

                if (ShowSources != null)
                {
                    hashCode = hashCode * 59 + ShowSources.GetHashCode();
                }

                if (DisplayModeBar != null)
                {
                    hashCode = hashCode * 59 + DisplayModeBar.GetHashCode();
                }

                if (ShowSendToCloud != null)
                {
                    hashCode = hashCode * 59 + ShowSendToCloud.GetHashCode();
                }

                if (ShowEditInChartStudio != null)
                {
                    hashCode = hashCode * 59 + ShowEditInChartStudio.GetHashCode();
                }

                if (ModeBarButtonsToRemove != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtonsToRemove.GetHashCode();
                }

                if (ModeBarButtonsToAdd != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtonsToAdd.GetHashCode();
                }

                if (ModeBarButtons != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtons.GetHashCode();
                }

                if (ToImageButtonOptions != null)
                {
                    hashCode = hashCode * 59 + ToImageButtonOptions.GetHashCode();
                }

                if (DisplayLogo != null)
                {
                    hashCode = hashCode * 59 + DisplayLogo.GetHashCode();
                }

                if (Watermark != null)
                {
                    hashCode = hashCode * 59 + Watermark.GetHashCode();
                }

                if (PlotGlPixelRatio != null)
                {
                    hashCode = hashCode * 59 + PlotGlPixelRatio.GetHashCode();
                }

                if (SetBackground != null)
                {
                    hashCode = hashCode * 59 + SetBackground.GetHashCode();
                }

                if (TopoJsonUrl != null)
                {
                    hashCode = hashCode * 59 + TopoJsonUrl.GetHashCode();
                }

                if (MapboxAccessToken != null)
                {
                    hashCode = hashCode * 59 + MapboxAccessToken.GetHashCode();
                }

                if (Logging != null)
                {
                    hashCode = hashCode * 59 + Logging.GetHashCode();
                }

                if (NotifyOnLogging != null)
                {
                    hashCode = hashCode * 59 + NotifyOnLogging.GetHashCode();
                }

                if (QueueLength != null)
                {
                    hashCode = hashCode * 59 + QueueLength.GetHashCode();
                }

                if (GlobalTransforms != null)
                {
                    hashCode = hashCode * 59 + GlobalTransforms.GetHashCode();
                }

                if (Locale != null)
                {
                    hashCode = hashCode * 59 + Locale.GetHashCode();
                }

                if (Locales != null)
                {
                    hashCode = hashCode * 59 + Locales.GetHashCode();
                }

                return(hashCode);
            }
        }
示例#7
0
        public bool Equals([AllowNull] Config other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((StaticPlot == other.StaticPlot && StaticPlot != null && other.StaticPlot != null && StaticPlot.Equals(other.StaticPlot)) &&
                   (PlotlyServerUrl == other.PlotlyServerUrl && PlotlyServerUrl != null && other.PlotlyServerUrl != null && PlotlyServerUrl.Equals(other.PlotlyServerUrl)) &&
                   (Editable == other.Editable && Editable != null && other.Editable != null && Editable.Equals(other.Editable)) &&
                   (Edits == other.Edits && Edits != null && other.Edits != null && Edits.Equals(other.Edits)) &&
                   (AutoSizable == other.AutoSizable && AutoSizable != null && other.AutoSizable != null && AutoSizable.Equals(other.AutoSizable)) &&
                   (Responsive == other.Responsive && Responsive != null && other.Responsive != null && Responsive.Equals(other.Responsive)) &&
                   (FillFrame == other.FillFrame && FillFrame != null && other.FillFrame != null && FillFrame.Equals(other.FillFrame)) &&
                   (FrameMargins == other.FrameMargins && FrameMargins != null && other.FrameMargins != null && FrameMargins.Equals(other.FrameMargins)) &&
                   (ScrollZoom == other.ScrollZoom && ScrollZoom != null && other.ScrollZoom != null && ScrollZoom.Equals(other.ScrollZoom)) &&
                   (DoubleClick == other.DoubleClick && DoubleClick != null && other.DoubleClick != null && DoubleClick.Equals(other.DoubleClick)) &&
                   (DoubleClickDelay == other.DoubleClickDelay && DoubleClickDelay != null && other.DoubleClickDelay != null && DoubleClickDelay.Equals(other.DoubleClickDelay)) &&
                   (ShowAxisDragHandles == other.ShowAxisDragHandles && ShowAxisDragHandles != null && other.ShowAxisDragHandles != null && ShowAxisDragHandles.Equals(other.ShowAxisDragHandles)) &&
                   (ShowAxisRangeEntryBoxes == other.ShowAxisRangeEntryBoxes &&
                    ShowAxisRangeEntryBoxes != null &&
                    other.ShowAxisRangeEntryBoxes != null &&
                    ShowAxisRangeEntryBoxes.Equals(other.ShowAxisRangeEntryBoxes)) &&
                   (ShowTips == other.ShowTips && ShowTips != null && other.ShowTips != null && ShowTips.Equals(other.ShowTips)) &&
                   (ShowLink == other.ShowLink && ShowLink != null && other.ShowLink != null && ShowLink.Equals(other.ShowLink)) &&
                   (LinkText == other.LinkText && LinkText != null && other.LinkText != null && LinkText.Equals(other.LinkText)) &&
                   (SendData == other.SendData && SendData != null && other.SendData != null && SendData.Equals(other.SendData)) &&
                   (ShowSources == other.ShowSources && ShowSources != null && other.ShowSources != null && ShowSources.Equals(other.ShowSources)) &&
                   (DisplayModeBar == other.DisplayModeBar && DisplayModeBar != null && other.DisplayModeBar != null && DisplayModeBar.Equals(other.DisplayModeBar)) &&
                   (ShowSendToCloud == other.ShowSendToCloud && ShowSendToCloud != null && other.ShowSendToCloud != null && ShowSendToCloud.Equals(other.ShowSendToCloud)) &&
                   (ShowEditInChartStudio == other.ShowEditInChartStudio &&
                    ShowEditInChartStudio != null &&
                    other.ShowEditInChartStudio != null &&
                    ShowEditInChartStudio.Equals(other.ShowEditInChartStudio)) &&
                   (ModeBarButtonsToRemove == other.ModeBarButtonsToRemove &&
                    ModeBarButtonsToRemove != null &&
                    other.ModeBarButtonsToRemove != null &&
                    ModeBarButtonsToRemove.Equals(other.ModeBarButtonsToRemove)) &&
                   (ModeBarButtonsToAdd == other.ModeBarButtonsToAdd && ModeBarButtonsToAdd != null && other.ModeBarButtonsToAdd != null && ModeBarButtonsToAdd.Equals(other.ModeBarButtonsToAdd)) &&
                   (ModeBarButtons == other.ModeBarButtons && ModeBarButtons != null && other.ModeBarButtons != null && ModeBarButtons.Equals(other.ModeBarButtons)) &&
                   (ToImageButtonOptions == other.ToImageButtonOptions &&
                    ToImageButtonOptions != null &&
                    other.ToImageButtonOptions != null &&
                    ToImageButtonOptions.Equals(other.ToImageButtonOptions)) &&
                   (DisplayLogo == other.DisplayLogo && DisplayLogo != null && other.DisplayLogo != null && DisplayLogo.Equals(other.DisplayLogo)) &&
                   (Watermark == other.Watermark && Watermark != null && other.Watermark != null && Watermark.Equals(other.Watermark)) &&
                   (PlotGlPixelRatio == other.PlotGlPixelRatio && PlotGlPixelRatio != null && other.PlotGlPixelRatio != null && PlotGlPixelRatio.Equals(other.PlotGlPixelRatio)) &&
                   (SetBackground == other.SetBackground && SetBackground != null && other.SetBackground != null && SetBackground.Equals(other.SetBackground)) &&
                   (TopoJsonUrl == other.TopoJsonUrl && TopoJsonUrl != null && other.TopoJsonUrl != null && TopoJsonUrl.Equals(other.TopoJsonUrl)) &&
                   (MapboxAccessToken == other.MapboxAccessToken && MapboxAccessToken != null && other.MapboxAccessToken != null && MapboxAccessToken.Equals(other.MapboxAccessToken)) &&
                   (Logging == other.Logging && Logging != null && other.Logging != null && Logging.Equals(other.Logging)) &&
                   (NotifyOnLogging == other.NotifyOnLogging && NotifyOnLogging != null && other.NotifyOnLogging != null && NotifyOnLogging.Equals(other.NotifyOnLogging)) &&
                   (QueueLength == other.QueueLength && QueueLength != null && other.QueueLength != null && QueueLength.Equals(other.QueueLength)) &&
                   (GlobalTransforms == other.GlobalTransforms && GlobalTransforms != null && other.GlobalTransforms != null && GlobalTransforms.Equals(other.GlobalTransforms)) &&
                   (Locale == other.Locale && Locale != null && other.Locale != null && Locale.Equals(other.Locale)) &&
                   (Locales == other.Locales && Locales != null && other.Locales != null && Locales.Equals(other.Locales)));
        }