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