NetMQ.Poller.TicklessTimer C# (CSharp) Method

TicklessTimer() private method

Return the soonest timeout value of all the timers in the list, or zero to indicate any of them have already elapsed. The timeout is in milliseconds from now.
private TicklessTimer ( ) : int
return int
        private int TicklessTimer()
        {
            // Calculate tickless timer,
            // by adding the timeout to the current point-in-time.
            long tickless = Clock.NowMs() + PollTimeout;

            // Find the When-value of the earliest timer..
            foreach (var timer in m_timers)
            {
                // If it is enabled but no When is set yet,
                if (timer.When == -1 && timer.Enable)
                {
                    // Set this timer's When to now plus it's Interval.
                    timer.When = timer.Interval + Clock.NowMs();
                }
                // If it has a When and that is earlier than the earliest found thus far,
                if (timer.When != -1 && tickless > timer.When)
                {
                    // save that value.
                    tickless = timer.When;
                }
            }
            // Compute a timeout value - how many milliseconds from now that that earliest-timer will expire.
            var timeout = (int)(tickless - Clock.NowMs());
            // Use zero to indicate it has already expired.
            if (timeout < 0)
            {
                timeout = 0;
            }
            // Return that timeout value.
            return timeout;
        }