refactor(modules): Defer cache rebuild
This commit is contained in:
parent
debb3534c7
commit
ba757809d0
@ -153,7 +153,8 @@ namespace modules {
|
||||
thread m_mainthread;
|
||||
|
||||
private:
|
||||
stateflag m_enabled{true};
|
||||
atomic<bool> m_enabled{true};
|
||||
atomic<bool> m_changed{true};
|
||||
string m_cache;
|
||||
};
|
||||
|
||||
|
@ -77,6 +77,11 @@ namespace modules {
|
||||
|
||||
template <typename Impl>
|
||||
string module<Impl>::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 <typename Impl>
|
||||
void module<Impl>::broadcast() {
|
||||
if (!running()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_cache = CAST_MOD(Impl)->get_output();
|
||||
m_changed = true;
|
||||
m_sig.emit(sig_ev::process_broadcast{});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user