Exemple #1
0
 protected override void EnusreWakingUp(bool inEventLoop)
 {
     if (_wakeUp)
     {
         _ = _timerHandle.Start(DefaultBreakoutTime, 0);
     }
 }
Exemple #2
0
        private void ShuttingDown()
        {
            Debug.Assert(InEventLoop);

            CancelScheduledTasks();

            if (0ul >= (ulong)_gracefulShutdownStartTime)
            {
                _gracefulShutdownStartTime = GetLoopTime();
            }

            bool runTask;

            do
            {
                runTask = RunAllTasks();

                // Terminate if the quiet period is 0.
                if (0ul >= (ulong)_gracefulShutdownQuietPeriod)
                {
                    StopLoop();
                    return;
                }
            }while (runTask);

            long nanoTime = GetLoopTime();

            // Shutdown timed out
            if (nanoTime - _gracefulShutdownStartTime <= _gracefulShutdownTimeout &&
                nanoTime - _lastExecutionTime <= _gracefulShutdownQuietPeriod)
            {
                // Wait for quiet period passed
                _ = _timerHandle.Start(DefaultBreakoutTime, 0); // 100ms
            }
            else
            {
                // No tasks were added for last quiet period
                StopLoop();
            }
        }
Exemple #3
0
 protected override void TaskDelay(int millisecondsTimeout)
 {
     _ = _timerHandle.Start(millisecondsTimeout, 0);
 }