mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-10-30 15:32:43 +01:00 
			
		
		
		
	Issue 1226/1497: Replace sleep_until with sleep_for to prevent clock from getting stuck with system time adjustment
This commit is contained in:
		| @@ -74,10 +74,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) | |||||||
|  |  | ||||||
|   thread_ = [this] { |   thread_ = [this] { | ||||||
|     dp.emit(); |     dp.emit(); | ||||||
|     auto now = std::chrono::system_clock::now(); |     thread_.sleep_for(interval_); | ||||||
|     auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_); |  | ||||||
|     auto diff = std::chrono::seconds(timeout.time_since_epoch().count() % interval_.count()); |  | ||||||
|     thread_.sleep_until(timeout - diff); |  | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,10 +6,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) | |||||||
|     : ALabel(config, "clock", id, "{:%H:%M}", 60) { |     : ALabel(config, "clock", id, "{:%H:%M}", 60) { | ||||||
|   thread_ = [this] { |   thread_ = [this] { | ||||||
|     dp.emit(); |     dp.emit(); | ||||||
|     auto now = std::chrono::system_clock::now(); |     thread_.sleep_for(interval_); | ||||||
|     auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_); |  | ||||||
|     auto diff = std::chrono::seconds(timeout.time_since_epoch().count() % interval_.count()); |  | ||||||
|     thread_.sleep_until(timeout - diff); |  | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rene D. Obermueller
					Rene D. Obermueller