event: make FineTimerEvent optional

Several applications don't need it, so let's eliminate the code from
the executable.
This commit is contained in:
Max Kellermann 2022-11-22 17:15:33 +01:00 committed by Max Kellermann
parent a750e4afa7
commit 74976d3199
2 changed files with 18 additions and 1 deletions

View File

@ -146,6 +146,8 @@ EventLoop::Insert(CoarseTimerEvent &t) noexcept
again = true; again = true;
} }
#ifndef NO_FINE_TIMER_EVENT
void void
EventLoop::Insert(FineTimerEvent &t) noexcept EventLoop::Insert(FineTimerEvent &t) noexcept
{ {
@ -167,12 +169,18 @@ GetEarlierTimeout(Event::Duration a, Event::Duration b) noexcept
: b; : b;
} }
#endif // NO_FINE_TIMER_EVENT
inline Event::Duration inline Event::Duration
EventLoop::HandleTimers() noexcept EventLoop::HandleTimers() noexcept
{ {
const auto now = SteadyNow(); const auto now = SteadyNow();
#ifndef NO_FINE_TIMER_EVENT
auto fine_timeout = timers.Run(now); auto fine_timeout = timers.Run(now);
#else
const Event::Duration fine_timeout{-1};
#endif // NO_FINE_TIMER_EVENT
auto coarse_timeout = coarse_timers.Run(now); auto coarse_timeout = coarse_timers.Run(now);
return GetEarlierTimeout(coarse_timeout, fine_timeout); return GetEarlierTimeout(coarse_timeout, fine_timeout);

View File

@ -22,13 +22,16 @@
#include "Chrono.hxx" #include "Chrono.hxx"
#include "TimerWheel.hxx" #include "TimerWheel.hxx"
#include "TimerList.hxx"
#include "Backend.hxx" #include "Backend.hxx"
#include "SocketEvent.hxx" #include "SocketEvent.hxx"
#include "event/Features.h" #include "event/Features.h"
#include "time/ClockCache.hxx" #include "time/ClockCache.hxx"
#include "util/IntrusiveList.hxx" #include "util/IntrusiveList.hxx"
#ifndef NO_FINE_TIMER_EVENT
#include "TimerList.hxx"
#endif // NO_FINE_TIMER_EVENT
#ifdef HAVE_THREADED_EVENT_LOOP #ifdef HAVE_THREADED_EVENT_LOOP
#include "WakeFD.hxx" #include "WakeFD.hxx"
#include "thread/Id.hxx" #include "thread/Id.hxx"
@ -64,7 +67,10 @@ class EventLoop final
#endif #endif
TimerWheel coarse_timers; TimerWheel coarse_timers;
#ifndef NO_FINE_TIMER_EVENT
TimerList timers; TimerList timers;
#endif // NO_FINE_TIMER_EVENT
using DeferList = IntrusiveList<DeferEvent>; using DeferList = IntrusiveList<DeferEvent>;
@ -226,7 +232,10 @@ public:
bool AbandonFD(SocketEvent &event) noexcept; bool AbandonFD(SocketEvent &event) noexcept;
void Insert(CoarseTimerEvent &t) noexcept; void Insert(CoarseTimerEvent &t) noexcept;
#ifndef NO_FINE_TIMER_EVENT
void Insert(FineTimerEvent &t) noexcept; void Insert(FineTimerEvent &t) noexcept;
#endif // NO_FINE_TIMER_EVENT
/** /**
* Schedule a call to DeferEvent::RunDeferred(). * Schedule a call to DeferEvent::RunDeferred().