From 4366c36704521c122bdd02200932c479f94c3e3f Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Tue, 21 Jun 2016 05:01:45 +0200 Subject: [PATCH] feat: Const methods for module broadcast throttle --- include/modules/base.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/modules/base.hpp b/include/modules/base.hpp index 734db44a..f1b3813e 100644 --- a/include/modules/base.hpp +++ b/include/modules/base.hpp @@ -105,11 +105,19 @@ namespace modules std::unique_ptr formatter; std::vector threads; + event_throttler::limit_t broadcast_throttler_limit() const { + return event_throttler::limit_t(1); + } + + event_throttler::timewindow_t broadcast_throttler_timewindow() const { + return event_throttler::timewindow_t(25); + } + public: Module(std::string name, bool lazy_builder = true) : name_("module/"+ name) , builder(std::make_unique(lazy_builder)) - , broadcast_throttler(std::make_unique(event_throttler::limit_t(1), event_throttler::timewindow_t(25))) + , broadcast_throttler(std::make_unique(ConstCastModule(ModuleImpl).broadcast_throttler_limit(), ConstCastModule(ModuleImpl).broadcast_throttler_timewindow())) { this->enable(false); this->cache = ""; @@ -200,7 +208,7 @@ namespace modules void wakeup() { log_trace("Releasing sleep lock for "+ this->name_); - this->sleep_handler.notify_one(); + this->sleep_handler.notify_all(); } std::string get_format() { @@ -399,7 +407,7 @@ namespace modules } public: - InotifyModule(std::string name) + explicit InotifyModule(std::string name) : Module(name) , poll_throttler(std::make_unique(event_throttler::limit_t(ThrottleLimit), event_throttler::timewindow_t(ThrottleWindowMs))) {}