Пример #1
0
 private EventScheduler(ILogFile log)
 {
     _log = log;
     _repo = SchedulerRepo.NewSync();
     _thr = ForeverThread.New(thread_loop, log);
     _hasNewTriger = new AutoResetEvent(false);
 }
Пример #2
0
 private TcpAcceptor(int port, ILogFile log, AcceptedCallback acceptedCallback)
 {
     _log = log;
     _port = port;
     _acceptedCallback = acceptedCallback;
     _thr = ForeverThread.New(accepting_loop, log);
     _acceptor = new TcpListener(IPAddress.Any, _port);
 }
Пример #3
0
        private IForeverThread[] create_threads(int count)
        {
            var threads = new IForeverThread[count];

            for (int indx = 0; indx < count; indx++)
            {
                IForeverThread thr = null;
                thr = ForeverThread.New(() => thread_loop(thr), _log);        // access to modified closure: use it to initialize thread loop

                threads[indx] = thr;
            }

            return threads;
        }
Пример #4
0
        private void thread_loop(IForeverThread thr)
        {
            _log.Trace("IoThread is started");

            while (true)
            {
                if (thr.StopRequestIsPosted())
                    break;

                bool mightHaveMoreWork = process_io();

                if (mightHaveMoreWork)
                    continue;

                Thread.Sleep(1);
            }

            _log.Trace("IoThread is done");
        }