mirror of
https://github.com/polybar/polybar.git
synced 2026-03-29 19:46:49 +00:00
refactor: Cleanup
This commit is contained in:
@ -1,13 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "modules/meta/base.hpp"
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
namespace chrono = std::chrono;
|
||||
|
||||
namespace modules {
|
||||
using interval_t = chrono::duration<double>;
|
||||
|
||||
@ -21,27 +17,27 @@ namespace modules {
|
||||
}
|
||||
|
||||
protected:
|
||||
interval_t m_interval{1};
|
||||
|
||||
void runner() {
|
||||
try {
|
||||
while (CONST_MOD(Impl).running()) {
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(this->m_updatelock);
|
||||
while (this->running()) {
|
||||
std::unique_lock<std::mutex> guard(this->m_updatelock);
|
||||
|
||||
if (CAST_MOD(Impl)->update())
|
||||
this->broadcast();
|
||||
if (CAST_MOD(Impl)->update()) {
|
||||
this->broadcast();
|
||||
}
|
||||
if (CONST_MOD(Impl).running()) {
|
||||
|
||||
if (this->running()) {
|
||||
guard.unlock();
|
||||
this->sleep(m_interval);
|
||||
}
|
||||
}
|
||||
} catch (const module_error& err) {
|
||||
this->halt(err.what());
|
||||
} catch (const std::exception& err) {
|
||||
} catch (const exception& err) {
|
||||
this->halt(err.what());
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
interval_t m_interval{1};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user