1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-12-02 14:05:27 -05:00
polybar/include/modules/meta/timer_module.inl
Michael Carlberg b417c9f812 feat(github): New module
Module used to query the GitHub API for information.
Currently only supports notification count.

Ref #84
2016-12-19 22:12:31 +01:00

38 lines
807 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<std::mutex> guard(this->m_updatelock);
if (CAST_MOD(Impl)->update())
CAST_MOD(Impl)->broadcast();
}
if (CONST_MOD(Impl).running()) {
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