util/IntrusiveSortedList: new class

This commit is contained in:
Max Kellermann
2022-11-13 08:51:18 +01:00
parent 85ab89a08b
commit 51769c40d8
4 changed files with 114 additions and 11 deletions
-8
View File
@@ -54,15 +54,7 @@ TimerList::~TimerList() noexcept
void
TimerList::Insert(FineTimerEvent &t) noexcept
{
#ifdef NO_BOOST
auto i = std::find_if(timers.begin(), timers.end(), [due = t.GetDue()](const auto &other){
return other.GetDue() >= due;
});
timers.insert(i, t);
#else
timers.insert(t);
#endif
}
Event::Duration
+4 -3
View File
@@ -34,9 +34,10 @@
#include "Chrono.hxx"
#include "event/Features.h"
#include "util/IntrusiveList.hxx"
#ifndef NO_BOOST
#ifdef NO_BOOST
#include "util/IntrusiveSortedList.hxx"
#else
#include <boost/intrusive/set.hpp>
#endif
@@ -55,7 +56,7 @@ class TimerList final {
/* 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 */
IntrusiveList<FineTimerEvent> timers;
IntrusiveSortedList<FineTimerEvent, Compare> timers;
#else
boost::intrusive::multiset<FineTimerEvent,
boost::intrusive::base_hook<boost::intrusive::set_base_hook<boost::intrusive::link_mode<boost::intrusive::auto_unlink>>>,