diff --git a/include/modules/meta/base.hpp b/include/modules/meta/base.hpp index f842e907..60a82e5e 100644 --- a/include/modules/meta/base.hpp +++ b/include/modules/meta/base.hpp @@ -158,6 +158,7 @@ namespace modules { bool visible() const override; + void start() override; void join() final override; void stop() override; void halt(string error_message) override; @@ -218,7 +219,7 @@ namespace modules { bool m_handle_events{true}; private: - atomic m_enabled{true}; + atomic m_enabled{false}; atomic m_visible{true}; atomic m_changed{true}; string m_cache; diff --git a/include/modules/meta/base.inl b/include/modules/meta/base.inl index ab53cb59..0d3bd82c 100644 --- a/include/modules/meta/base.inl +++ b/include/modules/meta/base.inl @@ -65,6 +65,11 @@ namespace modules { return static_cast(m_enabled); } + template + void module::start() { + m_enabled = true; + } + template void module::join() { for (auto&& thread_ : m_threads) { diff --git a/include/modules/meta/event_module.hpp b/include/modules/meta/event_module.hpp index 025fdccd..05d37050 100644 --- a/include/modules/meta/event_module.hpp +++ b/include/modules/meta/event_module.hpp @@ -11,6 +11,7 @@ namespace modules { using module::module; void start() override { + this->module::start(); this->m_mainthread = thread(&event_module::runner, this); } diff --git a/include/modules/meta/inotify_module.hpp b/include/modules/meta/inotify_module.hpp index 2c69e948..06877c14 100644 --- a/include/modules/meta/inotify_module.hpp +++ b/include/modules/meta/inotify_module.hpp @@ -12,6 +12,7 @@ namespace modules { using module::module; void start() override { + this->module::start(); this->m_mainthread = thread(&inotify_module::runner, this); } diff --git a/include/modules/meta/static_module.hpp b/include/modules/meta/static_module.hpp index 8bbef10f..ce4758a4 100644 --- a/include/modules/meta/static_module.hpp +++ b/include/modules/meta/static_module.hpp @@ -11,6 +11,7 @@ namespace modules { using module::module; void start() override { + this->module::start(); CAST_MOD(Impl)->update(); CAST_MOD(Impl)->broadcast(); } diff --git a/include/modules/meta/timer_module.hpp b/include/modules/meta/timer_module.hpp index e2ca716a..a9ede914 100644 --- a/include/modules/meta/timer_module.hpp +++ b/include/modules/meta/timer_module.hpp @@ -13,6 +13,7 @@ namespace modules { using module::module; void start() override { + this->module::start(); this->m_mainthread = thread(&timer_module::runner, this); } diff --git a/src/modules/ipc.cpp b/src/modules/ipc.cpp index 76bcaa6c..9aba10be 100644 --- a/src/modules/ipc.cpp +++ b/src/modules/ipc.cpp @@ -68,6 +68,7 @@ namespace modules { * Start module and run first defined hook if configured to */ void ipc_module::start() { + this->module::start(); m_mainthread = thread([&] { m_log.trace("%s: Thread id = %i", this->name(), concurrency_util::thread_id(this_thread::get_id())); update(); diff --git a/src/modules/script.cpp b/src/modules/script.cpp index 983ac8c9..71fe714a 100644 --- a/src/modules/script.cpp +++ b/src/modules/script.cpp @@ -33,6 +33,7 @@ namespace modules { * Start the module worker */ void script_module::start() { + this->module::start(); m_mainthread = thread([&] { try { while (running()) {