Issue 1226/1497: align updates with times divisible by interval
This commit is contained in:
parent
e5d05baba3
commit
4e3f91d237
|
@ -74,7 +74,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
|||
|
||||
thread_ = [this] {
|
||||
dp.emit();
|
||||
thread_.sleep_for(interval_);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
/* difference with projected wakeup time */
|
||||
auto diff = now.time_since_epoch() % interval_;
|
||||
/* sleep until the next projected time */
|
||||
thread_.sleep_for(interval_ - diff);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
|||
: ALabel(config, "clock", id, "{:%H:%M}", 60) {
|
||||
thread_ = [this] {
|
||||
dp.emit();
|
||||
thread_.sleep_for(interval_);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
/* difference with projected wakeup time */
|
||||
auto diff = now.time_since_epoch() % interval_;
|
||||
/* sleep until the next projected time */
|
||||
thread_.sleep_for(interval_ - diff);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue