use steady clock instead of system clock

This commit is contained in:
Jérôme BOULMIER 2019-04-04 21:36:33 -04:00 committed by Patrick Ziegler
parent e6e010e45b
commit 982a22cd62
2 changed files with 8 additions and 5 deletions

View File

@ -160,8 +160,11 @@ namespace modules {
*/
void battery_module::start() {
this->inotify_module::start();
// We only start animation thread if there is at least one animation.
if (m_animation_charging || m_animation_discharging) {
m_subthread = thread(&battery_module::subthread, this);
}
}
/**
* Release wake lock when stopping the module
@ -345,13 +348,13 @@ namespace modules {
m_log.trace("%s: Start of subthread", name());
while (running()) {
auto now = chrono::system_clock::now();
auto now = chrono::steady_clock::now();
auto framerate = 1000U; // milliseconds
if (m_state == battery_module::state::CHARGING) {
if (m_state == battery_module::state::CHARGING && m_animation_charging) {
m_animation_charging->increment();
broadcast();
framerate = m_animation_charging->framerate();
} else if (m_state == battery_module::state::DISCHARGING) {
} else if (m_state == battery_module::state::DISCHARGING && m_animation_discharging) {
m_animation_discharging->increment();
broadcast();
framerate = m_animation_discharging->framerate();

View File

@ -176,7 +176,7 @@ namespace modules {
const chrono::milliseconds framerate{m_animation_packetloss->framerate()};
while (running()) {
auto now = chrono::system_clock::now();
auto now = chrono::steady_clock::now();
if (m_connected && m_packetloss) {
m_animation_packetloss->increment();
broadcast();