-
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
Make this_thread::sleep_until
clock-aware
#3914
Make this_thread::sleep_until
clock-aware
#3914
Conversation
There are still the following functions: _CRTIMP2_PURE int __cdecl _Mtx_timedlock(_Mtx_t, const xtime*);
_CRTIMP2_PURE int __cdecl _Cnd_timedwait(_Cnd_t, _Mtx_t, const xtime*); I think we should either not resolve the original issue or create a follow-up issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaving these comments in my capacity as an individual; I'm no longer a maintainer and won't be following this PR going forward, but I think the folks who actually are maintainers should consider them. In particular, I feel strongly that ns
is not the correct type when all platform APIs speak FILETIME
100ns units. (The other comments are really nitpicks)
In this pr, should I:
I think these can be quality enhancements in the future:
|
Though a bit off-topic, I think it's not harmful to make a push to add Lines 428 to 439 in fc444ce
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
In my opinion, the separately compiled code should generally be a thin wrapper over the Windows API. Except when we need modifiable global state, the purpose of the DLL/LIB is to avoid dragging in |
|
I originally implemented them header-only! 😸 (And while there are throughput advantages to separately compiling them, there are also costs - we will never be able to remove them even after switching algorithms.) Basically there are always reasons for special exceptions, but that's the general rule - code in headers is more flexible and less burdensome for maintenance. |
By achabense: I’m sorry that I cannot take part in development these days. Before this I’ve made a feedback branch to 1. make _Thrd_sleep_for a direct call to Sleep. 2. merge _Reltime… template into sleep_for, as I think its too early to generalize this utility. Please help mark this pr work in progress temporarily, I will go back as soon as I have time(maybe several days later). |
This comment was marked as outdated.
This comment was marked as outdated.
Yes, after a brief glance the direction of that branch looks good to us; by the way, we now use |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I've changed my pr description to avoid closing the original issue. |
…into _Thread_sleep_fix2
Can we also add back the piece of test mentioned in #1642? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll push changes for these nearly non-functional comments.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
🧵 💤 ⏰ |
Incidentally, this change appears to be a breaking change. I recently built the
As soon as I upgraded my other PC to Visual Studio 2022 build 17.9 the link succeeded. FYI. |
This is expected. |
Yep. This is documented at https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170 . |
Partially addresses #718.
Fixes
this_thread::sleep_until / sleep_for
:_Thrd_sleep
with_Thrd_sleep_for
, which is a direct call to windowsSleep
(_Thrd_sleep
also relies onSleep
, but is bound to system-clock)._To_timespec64_sys_10_day_clamped
with clock-aware logic insleep_until
.Thanks to @AlexGuteniev for helping me figure out how to add import-library functions ❤️