mirror of
https://github.com/polybar/polybar.git
synced 2024-11-11 13:50:56 -05:00
36 lines
762 B
Text
36 lines
762 B
Text
|
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
|