From: Otto Moerbeek Date: Fri, 28 Jun 2024 13:17:59 +0000 (+0200) Subject: Untemplatize Throttle class X-Git-Tag: rec-5.2.0-alpha1~201^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c60be58a368c4017487f3b6de7a6c48142f8854;p=thirdparty%2Fpdns.git Untemplatize Throttle class --- diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 3a19b0bfcd..b504f66fd4 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -245,26 +245,33 @@ public: static LockGuarded s_nsSpeeds; -template -class Throttle : public boost::noncopyable +class Throttle { public: + Throttle() = default; + ~Throttle() = default; + Throttle(Throttle&&) = delete; + Throttle& operator=(const Throttle&) = default; + Throttle& operator=(Throttle&&) = delete; + Throttle(const Throttle&) = delete; + + using Key = std::tuple; struct entry_t { - entry_t(const Thing& thing_, time_t ttd_, unsigned int count_) : - thing(thing_), ttd(ttd_), count(count_) + entry_t(Key thing_, time_t ttd_, unsigned int count_) : + thing(std::move(thing_)), ttd(ttd_), count(count_) { } - Thing thing; + Key thing; time_t ttd; mutable unsigned int count; }; using cont_t = multi_index_container, member>, + ordered_unique, member>, ordered_non_unique, member>>>; - bool shouldThrottle(time_t now, const Thing& arg) + bool shouldThrottle(time_t now, const Key& arg) { auto iter = d_cont.find(arg); if (iter == d_cont.end()) { @@ -279,7 +286,7 @@ public: return true; // still listed, still blocked } - void throttle(time_t now, const Thing& arg, time_t ttl, unsigned int count) + void throttle(time_t now, const Key& arg, time_t ttl, unsigned int count) { auto iter = d_cont.find(arg); time_t ttd = now + ttl; @@ -289,7 +296,7 @@ public: else if (ttd > iter->ttd || count > iter->count) { ttd = std::max(iter->ttd, ttd); count = std::max(iter->count, count); - auto& ind = d_cont.template get(); + auto& ind = d_cont.template get(); ind.modify(iter, [ttd, count](entry_t& entry) { entry.ttd = ttd; entry.count = count; }); } } @@ -309,7 +316,7 @@ public: d_cont.clear(); } - void clear(const Thing& thing) + void clear(const Key& thing) { d_cont.erase(thing); } @@ -323,7 +330,7 @@ private: cont_t d_cont; }; -static LockGuarded>> s_throttle; +static LockGuarded s_throttle; struct SavedParentEntry {