I have some code that uses condition_variable. When the system clock gets set backwards, the condition_variable will wait for much longer because it uses system_clock instead of steady_clock. I have seen some workarounds posted here for this issue. Here is a previous thread How do I deal with the system clock changing while waiting on a std::condition_variable? None of the workarounds seemed particularly elegant. In my case I am doing a cross-compile for an embedded linux system. I considered fixing the problem by moving the condition_variable include file into my project and changing it to use chrono::steady_clock instead of chrono::system_clock. I don't like changing system include files. Two questions: 1. Is there a reason for condition_variable to use system_clock? Why is system_clock used in the standard include? Seems to me that changing the standard include to use steady_clock would not break any code. 2. Does anyone have a better suggestion?
Asked
Active
Viewed 273 times
3
-
*”I have some code that uses conditional_variable.”* Would be able to share any of that code in your question? As it is, this is a very interesting question, but you could make it easier for community members to give help by providing more details. – NicholasM Feb 08 '20 at 20:20
-
Sorry, I can't share the code. I have edited the question to include a reference to a previous discussion thread on this issue. – JVW Feb 10 '20 at 07:36