mirror of
https://github.com/polybar/polybar.git
synced 2024-10-27 05:23:39 -04:00
52 lines
1.1 KiB
Text
52 lines
1.1 KiB
Text
|
POLYBAR_NS
|
||
|
|
||
|
namespace modules {
|
||
|
// public {{{
|
||
|
|
||
|
template <class Impl>
|
||
|
void event_module<Impl>::start() {
|
||
|
CAST_MOD(Impl)->m_mainthread = thread(&event_module::runner, this);
|
||
|
}
|
||
|
|
||
|
// }}}
|
||
|
// protected {{{
|
||
|
|
||
|
template <class Impl>
|
||
|
void event_module<Impl>::runner() {
|
||
|
try {
|
||
|
// Send initial broadcast to warmup cache
|
||
|
if (CONST_MOD(Impl).running()) {
|
||
|
CAST_MOD(Impl)->update();
|
||
|
CAST_MOD(Impl)->broadcast();
|
||
|
}
|
||
|
|
||
|
while (CONST_MOD(Impl).running()) {
|
||
|
CAST_MOD(Impl)->idle();
|
||
|
|
||
|
if (!CONST_MOD(Impl).running())
|
||
|
break;
|
||
|
|
||
|
std::lock_guard<concurrency_util::spin_lock> guard(this->m_lock);
|
||
|
{
|
||
|
if (!CAST_MOD(Impl)->has_event())
|
||
|
continue;
|
||
|
if (!CONST_MOD(Impl).running())
|
||
|
break;
|
||
|
if (!CAST_MOD(Impl)->update())
|
||
|
continue;
|
||
|
|
||
|
CAST_MOD(Impl)->broadcast();
|
||
|
}
|
||
|
}
|
||
|
} 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
|