diff --git a/src/event/FineTimerEvent.hxx b/src/event/FineTimerEvent.hxx index e0cd15d94..65781f947 100644 --- a/src/event/FineTimerEvent.hxx +++ b/src/event/FineTimerEvent.hxx @@ -11,7 +11,7 @@ #ifdef NO_BOOST #include "util/IntrusiveList.hxx" #else -#include +#include "util/IntrusiveTreeSet.hxx" #endif #include @@ -33,7 +33,7 @@ class FineTimerEvent final : #ifdef NO_BOOST AutoUnlinkIntrusiveListHook #else - public boost::intrusive::set_base_hook> + public IntrusiveTreeSetHook #endif { friend class TimerList; diff --git a/src/event/TimerList.cxx b/src/event/TimerList.cxx index 9d3ab9a3f..9b134a8a2 100644 --- a/src/event/TimerList.cxx +++ b/src/event/TimerList.cxx @@ -5,6 +5,14 @@ #include "TimerList.hxx" #include "FineTimerEvent.hxx" +constexpr Event::TimePoint +TimerList::GetDue::operator()(const FineTimerEvent &timer) const noexcept +{ + return timer.due; +} + +#ifdef NO_BOOST + constexpr bool TimerList::Compare::operator()(const FineTimerEvent &a, const FineTimerEvent &b) const noexcept @@ -12,6 +20,8 @@ TimerList::Compare::operator()(const FineTimerEvent &a, return a.due < b.due; } +#endif + TimerList::TimerList() = default; TimerList::~TimerList() noexcept @@ -41,7 +51,7 @@ TimerList::Run(const Event::TimePoint now) noexcept #ifdef NO_BOOST t.Cancel(); #else - timers.erase(i); + timers.pop_front(); #endif t.Run(); diff --git a/src/event/TimerList.hxx b/src/event/TimerList.hxx index 1428f488b..513688740 100644 --- a/src/event/TimerList.hxx +++ b/src/event/TimerList.hxx @@ -10,7 +10,7 @@ #ifdef NO_BOOST #include "util/IntrusiveSortedList.hxx" #else -#include +#include "util/IntrusiveTreeSet.hxx" #endif class FineTimerEvent; @@ -19,21 +19,23 @@ class FineTimerEvent; * A list of #FineTimerEvent instances sorted by due time point. */ class TimerList final { + struct GetDue { + constexpr Event::TimePoint operator()(const FineTimerEvent &timer) const noexcept; + }; + +#ifdef NO_BOOST struct Compare { constexpr bool operator()(const FineTimerEvent &a, const FineTimerEvent &b) const noexcept; }; -#ifdef NO_BOOST /* when building without Boost, then this is just a sorted doubly-linked list - this doesn't scale well, but is good enough for most programs */ IntrusiveSortedList timers; #else - boost::intrusive::multiset>>, - boost::intrusive::compare, - boost::intrusive::constant_time_size> timers; + IntrusiveTreeSet> timers; #endif public: