event/Loop: move code to GetEarlierTimeout()
This commit is contained in:
parent
c122e990a3
commit
a750e4afa7
|
@ -155,6 +155,18 @@ EventLoop::Insert(FineTimerEvent &t) noexcept
|
|||
again = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which timeout will happen earlier; either one may be
|
||||
* negative to specify "no timeout at all".
|
||||
*/
|
||||
static constexpr Event::Duration
|
||||
GetEarlierTimeout(Event::Duration a, Event::Duration b) noexcept
|
||||
{
|
||||
return b.count() < 0 || (a.count() >= 0 && a < b)
|
||||
? a
|
||||
: b;
|
||||
}
|
||||
|
||||
inline Event::Duration
|
||||
EventLoop::HandleTimers() noexcept
|
||||
{
|
||||
|
@ -163,10 +175,7 @@ EventLoop::HandleTimers() noexcept
|
|||
auto fine_timeout = timers.Run(now);
|
||||
auto coarse_timeout = coarse_timers.Run(now);
|
||||
|
||||
return fine_timeout.count() < 0 ||
|
||||
(coarse_timeout.count() >= 0 && coarse_timeout < fine_timeout)
|
||||
? coarse_timeout
|
||||
: fine_timeout;
|
||||
return GetEarlierTimeout(coarse_timeout, fine_timeout);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue