diff --git a/include/modules/meta/base.hpp b/include/modules/meta/base.hpp index 7dffb169..0aa82690 100644 --- a/include/modules/meta/base.hpp +++ b/include/modules/meta/base.hpp @@ -153,7 +153,8 @@ namespace modules { thread m_mainthread; private: - stateflag m_enabled{true}; + atomic m_enabled{true}; + atomic m_changed{true}; string m_cache; }; diff --git a/include/modules/meta/base.inl b/include/modules/meta/base.inl index 217c93cf..9c0c6d62 100644 --- a/include/modules/meta/base.inl +++ b/include/modules/meta/base.inl @@ -77,6 +77,11 @@ namespace modules { template string module::contents() { + if (m_changed) { + m_log.info("Rebuilding cache for '%s'...", name()); + m_cache = CAST_MOD(Impl)->get_output(); + m_changed = false; + } return m_cache; } @@ -85,11 +90,7 @@ namespace modules { template void module::broadcast() { - if (!running()) { - return; - } - - m_cache = CAST_MOD(Impl)->get_output(); + m_changed = true; m_sig.emit(sig_ev::process_broadcast{}); }