-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Wait condition_variable_any
for steady_clock
#4755
Conversation
condition_variable
for steady_clock
condition_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! ⏳ 🐞 😻 |
Fixes #4723
Turned out that:
SleepConditionVariableSRW
times out using a steady clock that is not precisely synchronized withsteady_clock
implemented based onQueryPerformanceCounter
GetTickCount64()
check doesn't help, asGetTickCount64()
is also not precisely synchronized withQueryPerformanceCounter
The fix is to check exactly
steady_clock
incondition_variable_any
.This is done in a header, rather than in
.cpp
for 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 rawSleepConditionVariableSRW
a bit).I've inlined
_Wait_for_ms_count
as to me it appeared clearer this way after these changes.