private StpIsolationThreadPool CreateAndStartPool(int threadCount, int queueLength)
 {
     var pool = new StpIsolationThreadPool(
         GroupKey.Named("Test"),
         new TransientConfigurableValue<int>(threadCount),
         new TransientConfigurableValue<int>(queueLength),
         new IgnoringStats());
     pool.Start();
     return pool;
 }
Пример #2
0
        private StpIsolationThreadPool CreateAndStartPool(int threadCount, int queueLength)
        {
            var pool = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue <int>(threadCount),
                new TransientConfigurableValue <int>(queueLength),
                new IgnoringStats());

            pool.Start();
            return(pool);
        }
        public void Start_Elapsed()
        {
            var mockStats = new Mock <IStats>();
            var pool      = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue <int>(10),
                new TransientConfigurableValue <int>(20),
                mockStats.Object);

            pool.Start();

            mockStats.Verify(m => m.Elapsed("mjolnir pool Test Start", null, It.IsAny <TimeSpan>()), Times.Once);
        }
        public void Start_Elapsed()
        {
            var mockStats = new Mock<IStats>();
            var pool = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue<int>(10),
                new TransientConfigurableValue<int>(20),
                mockStats.Object);

            pool.Start();

            mockStats.Verify(m => m.Elapsed("mjolnir pool Test Start", null, It.IsAny<TimeSpan>()), Times.Once);
        }
        public void Enqueue_Elapsed()
        {
            var mockStats = new Mock<IStats>();
            var mockMetricEvents = new Mock<IMetricEvents>();
            var pool = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue<int>(10),
                new TransientConfigurableValue<int>(20),
                mockStats.Object,
                mockMetricEvents.Object);
            pool.Start();

            pool.Enqueue<object>(() => new { });

            mockStats.Verify(m => m.Elapsed("mjolnir pool Test Enqueue", "Enqueued", It.IsAny<TimeSpan>()), Times.Once);
        }
        public async Task Construct_CreatesGauges()
        {
            const long gaugeIntervalMillis = 50;

            var mockStats = new Mock <IStats>();
            var pool      = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue <int>(10),
                new TransientConfigurableValue <int>(20),
                mockStats.Object,
                new TransientConfigurableValue <long>(gaugeIntervalMillis));

            await Task.Delay(TimeSpan.FromMilliseconds(gaugeIntervalMillis + 50));

            mockStats.Verify(m => m.Gauge("mjolnir pool Test activeThreads", null, It.IsAny <long>()), Times.AtLeastOnce);
            mockStats.Verify(m => m.Gauge("mjolnir pool Test inUseThreads", null, It.IsAny <long>()), Times.AtLeastOnce);
            mockStats.Verify(m => m.Gauge("mjolnir pool Test pendingCompletion", null, It.IsAny <long>()), Times.AtLeastOnce);
        }
        public async Task Construct_CreatesGauges()
        {
            const long gaugeIntervalMillis = 50;

            var mockStats = new Mock<IStats>();
            var pool = new StpIsolationThreadPool(
                GroupKey.Named("Test"),
                new TransientConfigurableValue<int>(10),
                new TransientConfigurableValue<int>(20),
                mockStats.Object,
                new TransientConfigurableValue<long>(gaugeIntervalMillis));

            await Task.Delay(TimeSpan.FromMilliseconds(gaugeIntervalMillis + 50));

            mockStats.Verify(m => m.Gauge("mjolnir pool Test activeThreads", null, It.IsAny<long>()), Times.AtLeastOnce);
            mockStats.Verify(m => m.Gauge("mjolnir pool Test inUseThreads", null, It.IsAny<long>()), Times.AtLeastOnce);
            mockStats.Verify(m => m.Gauge("mjolnir pool Test pendingCompletion", null, It.IsAny<long>()), Times.AtLeastOnce);
        }