예제 #1
0
 internal static void Reset()
 {
     CommandComponentsCollection.Clear();
     ExecutionSemaphores.Clear();
     FallbackExecutionSemaphores.Clear();
     CommandCount.GetAndSet(0);
     CustomBadRequestExceptionChecker.BadRequestExceptionCheckers.Clear();
 }
예제 #2
0
 public int GetAndSet(int newValue)
 {
     if (newValue < 0)
     {
         throw new ArgumentException("new value " + newValue + " < 0");
     }
     return(i.GetAndSet(newValue));
 }
예제 #3
0
        public void TestThatAFailureIsNotComposedWithAndThenTo()
        {
            var currentValue = new AtomicInteger(0);

            Failure.Of <Exception, int>(RandomException())
            .AndThenTo(val => Success.Of <Exception, int>(currentValue.GetAndSet(val)));

            Assert.Equal(0, currentValue.Get());
        }
예제 #4
0
        private void DoUpdates()
        {
            int cnt = pendingUpdates.GetAndSet(0);

            if (0 < cnt)
            {
                pm.Update(cnt);
            }
        }
예제 #5
0
        public T Choose(T[] items)
        {
            if (items == null || items.Length == 0)
            {
                return(default(T));
            }

            int counterValue = counter.GetAndIncrement();

            if (counterValue > MaxValue)
            {
                counter.GetAndSet(0);
            }

            int index = counterValue % items.Length;

            return(items[index]);
        }
예제 #6
0
        public void IncrementConcurrentExecutionCount()
        {
            var operationCount = concurrentExecutionCount.IncrementAndGet();

            if (operationCount > maxConcurrentExecutionCount.Value)
            {
                maxConcurrentExecutionCount.GetAndSet(operationCount);
            }
        }
예제 #7
0
        /// <summary>
        /// 服务并发量自增
        /// </summary>

        internal void IncrementConcurrentExecutionCount()
        {
            var serviceCount = serviceConcurrentExecutionCount.IncrementAndGet();

            if (serviceCount > serviceMaxConcurrentExecutionCount.Value)
            {
                serviceMaxConcurrentExecutionCount.GetAndSet(serviceCount);
            }
        }
예제 #8
0
 /// <summary>
 /// notify the input stream that there is no more data
 /// </summary>
 protected void noMoreData()
 {
     expectMoreData.GetAndSet(0);
 }
예제 #9
0
 public void can_get_and_set()
 {
     _num.SetValue(32);
     _num.GetAndSet(64).Should().Be(32);
     _num.GetValue().Should().Be(64);
 }