コード例 #1
0
 public EventManagerCoroutine(LockFreeQueue <CoroutineEventDescriptor> eventQueue, CounterInt64 counter,
                              Dictionary <string, Dictionary <Type, CoroutineEventDescriptor> > eventsDescriptors)
 {
     _eventsDescriptors     = eventsDescriptors;
     _eventDescriptorsQueue = eventQueue;
     _counter = counter;
 }
コード例 #2
0
        public void CounterInt64CompareExchangeFail()
        {
            var c   = new CounterInt64(1);
            var res = c.CompareExchange(2, 2);

            Assert.AreEqual(1, res);
        }
コード例 #3
0
 public EventDispatcher(LockFreeQueue <Coroutines.EventMessage> events, CoroutineThread[] threads, CounterInt64 counter, Dictionary <string, Dictionary <Type, CoroutineEventDescriptor> > eventsList)
 {
     _events     = events;
     _threads    = threads;
     _counter    = counter;
     _eventsList = eventsList;
 }
コード例 #4
0
 private void ResetData()
 {
     _dict    = new AsyncLockFreeDictionary <string, string>();
     _removed = new CounterInt64();
     _added   = new CounterInt64();
     _read    = new CounterInt64();
 }
コード例 #5
0
        public void CounterInt64GetAndReset()
        {
            var c      = new CounterInt64(22);
            var result = c.GetAndReset();

            Assert.AreEqual(result, 22);
            Assert.AreEqual(0, (Int64)c);
        }
コード例 #6
0
        public void CounterInt64SumBetweenCounters()
        {
            var c = new CounterInt64(22);
            var d = new CounterInt64(23);
            var e = c + d;

            Assert.AreEqual(45, (Int64)e);
        }
コード例 #7
0
        public void CounterInt64DecrementIncrement()
        {
            var c = new CounterInt64(22);

            c.Decrement();
            Assert.AreEqual(21, (Int64)c);
            c.Increment();
            Assert.AreEqual(22, (Int64)c);
        }
コード例 #8
0
        public void CounterInt64Int64Conversion()
        {
            const long int64Value = 28;
            const int  int32Value = 28;
            var        c          = new CounterInt64();

            c = int64Value;
            Assert.AreEqual(int64Value, (Int64)c);
            c = int32Value;
            Assert.AreEqual(int32Value, (Int32)c);
        }
コード例 #9
0
        public void CounterInt64PlusMinusOperators()
        {
            var c = new CounterInt64(22);

            c++;
            Assert.AreEqual(23, (Int64)c);
            c--;
            Assert.AreEqual(22, (Int64)c);
            c += 1;
            Assert.AreEqual(23, (Int64)c);
        }
コード例 #10
0
		public CoroutineThread(int cycleMaxMs = 10, int affinity = -1)
		{
			_startedCoroutines = new CounterInt64();
			_terminatedCoroutines = new CounterInt64();
			Status = (int)CoroutineThreadStatus.Stopped;
			_values = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			_cycleMaxMs = cycleMaxMs;
			_affinity = affinity;
			_coroutines = new List<CoroutineStatus>();
			_coroutinesQueue = new LockFreeQueue<ICoroutine>();
			_thread = new Thread(StartThread);
			_pauseVerifier = new ManualResetEvent(false);
			_currentCulture = Thread.CurrentThread.CurrentCulture;
		}
コード例 #11
0
        protected CoroutineEventThread(int threadsCount, int cycleMaxMs)
        {
            _eventQueue = new LockFreeQueue <CoroutineEventDescriptor>();
            _events     = new LockFreeQueue <EventMessage>();
            _eventsList = new Dictionary <string, Dictionary <Type, CoroutineEventDescriptor> >(StringComparer.OrdinalIgnoreCase);
            _counter    = new CounterInt64(0);
            if (threadsCount < 1)
            {
                threadsCount = 1;
            }
            _threadsCount = threadsCount;
            _threads      = new CoroutineThread[_threadsCount];
            _manager      = new CoroutineThread(1);
            _manager.AddCoroutine(new EventManagerCoroutine(_eventQueue, _counter, _eventsList));

            for (int i = 0; i < _threadsCount; i++)
            {
                _threads[i] = new CoroutineThread(cycleMaxMs);
            }
        }
コード例 #12
0
        public void CounterInt64Constructor()
        {
            var c = new CounterInt64(22);

            Assert.AreEqual(22, (Int64)c);
        }
コード例 #13
0
        public void CounterInt64ToStringOperator()
        {
            var c = new CounterInt64(22);

            Assert.AreEqual("22", c.ToString());
        }