Пример #1
0
        protected SingleThreadEventExecutorOld(IEventExecutorGroup parent, string threadName, TimeSpan breakoutInterval, IQueue <IRunnable> taskQueue)
            : base(parent)
        {
            _firstTask     = true;
            _emptyEvent    = new ManualResetEventSlim(false, 1);
            _shutdownHooks = new HashSet <Action>();

            _loopAction     = Loop;
            _loopCoreAciton = LoopCore;

            _terminationCompletionSource = NewPromise();
            _taskQueue = taskQueue;
            _preciseBreakoutInterval = PreciseTimeSpan.FromTimeSpan(breakoutInterval);
            _scheduler = new ExecutorTaskScheduler(this);
            _thread    = new Thread(_loopAction);
            if (string.IsNullOrEmpty(threadName))
            {
                _thread.Name = DefaultWorkerThreadName;
            }
            else
            {
                _thread.Name = threadName;
            }
            _thread.Start();
        }
Пример #2
0
        static void Schedule(Thread thread, Action task, bool isWatch)
        {
            PendingEntries.TryEnqueue(new Entry(thread, task, isWatch));

            if (Interlocked.CompareExchange(ref started, 1, 0) == 0)
            {
                var watcherThread = new Thread(s => ((IRunnable)s).Run());
                watcherThread.Start(watcher);
                ThreadDeathWatcher.watcherThread = watcherThread;
            }
        }
Пример #3
0
        static void Schedule(Thread thread, Action task, bool isWatch)
        {
            _ = PendingEntries.TryEnqueue(new Entry(thread, task, isWatch));

            if (SharedConstants.False >= (uint)Interlocked.CompareExchange(ref started, SharedConstants.True, SharedConstants.False))
            {
                var watcherThread = new Thread(s => ((IRunnable)s).Run());
                watcherThread.Start(watcher);
                _ = Interlocked.Exchange(ref ThreadDeathWatcher.watcherThread, watcherThread);
            }
        }
Пример #4
0
        protected SingleThreadEventExecutor(IEventExecutorGroup parent, string threadName, TimeSpan breakoutInterval, IQueue <IRunnable> taskQueue)
            : base(parent)
        {
            _loopAction     = Loop;
            _loopCoreAciton = LoopCore;

            _terminationCompletionSource = NewPromise();
            _taskQueue = taskQueue;
            _preciseBreakoutInterval = PreciseTimeSpan.FromTimeSpan(breakoutInterval);
            _scheduler = new ExecutorTaskScheduler(this);
            _thread    = new Thread(_loopAction);
            if (string.IsNullOrEmpty(threadName))
            {
                _thread.Name = DefaultWorkerThreadName;
            }
            else
            {
                _thread.Name = threadName;
            }
            _thread.Start();
        }
 protected virtual void Start()
 {
     _thread.Start();
 }