event/TimerWheel: optimized container for CoarseTimerEvent
This commit is contained in:

committed by
Max Kellermann

parent
d1957b83c8
commit
5a16e3ffa3
@@ -142,6 +142,13 @@ EventLoop::AbandonFD(SocketEvent &event) noexcept
|
||||
return poll_backend.Abandon(event.GetSocket().Get());
|
||||
}
|
||||
|
||||
void
|
||||
EventLoop::Insert(CoarseTimerEvent &t) noexcept
|
||||
{
|
||||
coarse_timers.Insert(t);
|
||||
again = true;
|
||||
}
|
||||
|
||||
void
|
||||
EventLoop::Insert(FineTimerEvent &t) noexcept
|
||||
{
|
||||
@@ -154,7 +161,15 @@ EventLoop::Insert(FineTimerEvent &t) noexcept
|
||||
inline Event::Duration
|
||||
EventLoop::HandleTimers() noexcept
|
||||
{
|
||||
return timers.Run(SteadyNow());
|
||||
const auto now = SteadyNow();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user