mirror of
https://github.com/polybar/polybar.git
synced 2024-11-18 13:55:11 -05:00
35 lines
762 B
C++
35 lines
762 B
C++
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
|