refactor: Cleanup

This commit is contained in:
Michael Carlberg
2016-12-21 23:22:02 +01:00
parent 185363056a
commit bc9b9f0d12
32 changed files with 276 additions and 311 deletions

View File

@ -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};
};
}