polybar-dwm/include/modules/meta/timer_module.inl

36 lines
762 B
Plaintext
Raw Normal View History

2016-11-20 22:04:31 +00:00
POLYBAR_NS
namespace modules {
// public {{{
template <typename Impl>
void timer_module<Impl>::start() {
CAST_MOD(Impl)->m_mainthread = thread(&timer_module::runner, this);
}
// }}}
// protected {{{
template <typename Impl>
void timer_module<Impl>::runner() {
try {
while (CONST_MOD(Impl).running()) {
std::lock_guard<concurrency_util::spin_lock> guard(this->m_lock);
{
if (CAST_MOD(Impl)->update())
CAST_MOD(Impl)->broadcast();
}
CAST_MOD(Impl)->sleep(m_interval);
}
} catch (const module_error& err) {
CAST_MOD(Impl)->halt(err.what());
} catch (const std::exception& err) {
CAST_MOD(Impl)->halt(err.what());
}
}
// }}}
}
POLYBAR_NS_END