-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Wait condition_variable_any for steady_clock
#4755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
condition_variable for steady_clockcondition_variable_any for steady_clock
|
Thanks! I pushed a conflict-free merge with I also fixed the title, because the correctness fix is specific to |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks for fixing this long-standing sporadic bug! ⏳ 🐞 😻 |
|
|
|
By design: #4457 (comment) |
Fixes #4723
Turned out that:
SleepConditionVariableSRWtimes out using a steady clock that is not precisely synchronized withsteady_clockimplemented based onQueryPerformanceCounterGetTickCount64()check doesn't help, asGetTickCount64()is also not precisely synchronized withQueryPerformanceCounterThe fix is to check exactly
steady_clockincondition_variable_any.This is done in a header, rather than in
.cppfor these reasons:steady_clock::now()is nontrivial, and resides in a non-core header, and we don't have a good core header to extract it intoThat's why
GetTickCount64()was removed from internal wait function.To avoid destabilizing behavior for already compiled code, I kept
GetTickCount64()on that code path (it might improve over rawSleepConditionVariableSRWa bit).I've inlined
_Wait_for_ms_countas to me it appeared clearer this way after these changes.