1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/meta/timer_module.inl

36 lines
762 B
Text
Raw Normal View History

2016-11-20 17:04:31 -05: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