public void ConcurrentInt64CompareExchangeFail()
        {
            var c   = new ConcurrentInt64(1);
            var res = c.CompareExchange(2, 2);

            Assert.AreEqual(1, res);
        }
 private void ResetData()
 {
     _dict    = new AsyncLockFreeDictionary <string, string>();
     _removed = new ConcurrentInt64();
     _added   = new ConcurrentInt64();
     _read    = new ConcurrentInt64();
 }
        private void OnSynchronize(object sender, ElapsedTimerEventArgs e)
        {
            var changesMade = false;

            if (1 == (int)_opverlappingChecker)
            {
                return;
            }
            _opverlappingChecker = 1;
            try
            {
                var maxMessages = (int)MaxMessagesPerCycle;
                foreach (var request in _requestsQueue.Dequeue(100))
                {
                    if (HandledEvent(request))
                    {
                        changesMade = true;
                    }
                    maxMessages--;
                    if (maxMessages <= 0)
                    {
                        break;
                    }
                }
                if (changesMade)
                {
                    _list.Data = new List <T>(_trustedSource);
                }
            }
            finally
            {
                _opverlappingChecker = 0;
            }
        }
        public void ConcurrentInt64GetAndSet()
        {
            var c      = new ConcurrentInt64(22);
            var result = c.GetAndSet(38);

            Assert.AreEqual(result, 22);
            Assert.AreEqual(38, (Int64)c);
        }
        public void ConcurrentInt64SumBetweenCounters()
        {
            var c = new ConcurrentInt64(22);
            var d = new ConcurrentInt64(23);
            var e = c + d;

            Assert.AreEqual(45, (Int64)e);
        }
        public void ConcurrentInt64DecrementIncrement()
        {
            var c = new ConcurrentInt64(22);

            c.Decrement();
            Assert.AreEqual(21, (Int64)c);
            c.Increment();
            Assert.AreEqual(22, (Int64)c);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LockFreeQueue()
        {
            _count = new ConcurrentInt64();
            // ReSharper disable CompareNonConstrainedGenericWithNull
            _isNullable = default(T) == null;
            // ReSharper restore CompareNonConstrainedGenericWithNull
            var node = new NodeT();

            _head._ptr = _tail._ptr = node;
        }
 public AsyncLockFreeList(IEnumerable <T> dictionary, ITimer timer = null)
 {
     MaxMessagesPerCycle  = new ConcurrentInt64(100);
     _opverlappingChecker = new ConcurrentInt64();
     _timer          = timer ?? new SystemTimer(10, 10);
     _list           = new LockFreeItem <List <T> >(new List <T>(dictionary));
     _trustedSource  = new List <T>();
     _requestsQueue  = new LockFreeQueue <AsyncCollectionRequest <T> >();
     _timer.Elapsed += OnSynchronize;
     _timer.Start();
 }
        public void ConcurrentInt64Int64Conversion()
        {
            const long int64Value = 28;
            const int  int32Value = 28;
            var        c          = new ConcurrentInt64();

            c = int64Value;
            Assert.AreEqual(int64Value, (Int64)c);
            c = int32Value;
            Assert.AreEqual(int32Value, (Int32)c);
        }
Exemplo n.º 10
0
        public void ConcurrentInt64PlusMinusOperators()
        {
            var c = new ConcurrentInt64(22);

            c++;
            Assert.AreEqual(23, (Int64)c);
            c--;
            Assert.AreEqual(22, (Int64)c);
            c += 1;
            Assert.AreEqual(23, (Int64)c);
        }
 public AsyncLockFreeDictionary(IDictionary <TKey, TValue> dictionary, ITimer timer = null)
 {
     MaxMessagesPerCycle  = new ConcurrentInt64(100);
     _opverlappingChecker = new ConcurrentInt64();
     _timer      = timer ?? new SystemTimer(10, 10);
     _dictionary = new LockFreeItem <Dictionary <TKey, TValue> >(new Dictionary <TKey, TValue>(dictionary))
     {
         Data =
             new Dictionary
             <TKey, TValue>()
     };
     _trustedSource  = new Dictionary <TKey, TValue>();
     _requestsQueue  = new LockFreeQueue <AsyncCollectionRequest <KeyValuePair <TKey, TValue> > >();
     _timer.Elapsed += OnSynchronize;
     _timer.Start();
 }
Exemplo n.º 12
0
 public ValueSample()
 {
     _startTimestamp   = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;
     _updatetTimestamp = new ConcurrentInt64(DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond);
 }
Exemplo n.º 13
0
        public void ConcurrentInt64Constructor()
        {
            var c = new ConcurrentInt64(22);

            Assert.AreEqual(22, (Int64)c);
        }
Exemplo n.º 14
0
        public void ConcurrentInt64ToStringOperator()
        {
            var c = new ConcurrentInt64(22);

            Assert.AreEqual("22", c.ToString());
        }
Exemplo n.º 15
0
		public MarkdownRenderer()
		{
			_renderer = new MarkdownSharp.Markdown();
			_locker = new ConcurrentInt64();
		}