Exemple #1
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);
            }
        }
 public static Step InvokeCoroutineAndWait(CoroutineThread thread, ICoroutine action, bool adding = true)
 {
     if (InterceptExternalCalls)
     {
         var result = Interceptor(action, null);
         if (result.TerminateHere)
         {
             return(result.RealStep);
         }
     }
     if (adding)
     {
         thread.AddCoroutine(action);
     }
     return(Step.DataStep(new EnumeratorWrapper
     {
         Culture = System.Threading.Thread.CurrentThread.CurrentCulture,
         IsCoroutine = true,
         SubCoroutine = action,
     }));
 }