rust/library/std
Jacob Pratt 15ce06c931
Rollup merge of #151494 - joboet:sleep_until_ensure_elapsed, r=jhpratt
std: ensure that the deadline has passed in `sleep_until`

The clock source used for `sleep` might not be the same as the one used for `Instant`, so the implementation of `sleep_until` may not assume that the `Instant` has elapsed. This is particularly relevant on Windows, where [`QueryPerformanceCounter`](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter) is used for `Instant`, but [`SetWaitableTimer`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-setwaitabletimer) is (probably[^1]) based on [`QueryUnbiasedInterruptTimePrecise`](https://learn.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryunbiasedinterrupttimeprecise). If these clocks drift apart, the `sleep` might return before the deadline has passed.

Thus, this PR makes `sleep_until` recheck the current time after waking up and restart the `sleep` if necessary.

[^1]: The documentation doesn't specify a clock, but `QueryUnbiasedInterruptTimePrecise` uses the same units and doesn't count time during sleep either, so I'd wager it's what is used for the timer.
2026-01-22 20:16:51 -05:00
..
benches benchmark path.components() iteration 2025-10-25 14:46:58 +02:00
src Rollup merge of #151494 - joboet:sleep_until_ensure_elapsed, r=jhpratt 2026-01-22 20:16:51 -05:00
tests time: Add saturating arithmetic for SystemTime 2026-01-16 11:52:01 +01:00
build.rs Update to new API, allowing to remove check_doc_cfg.rs file from librustdoc 2025-12-10 12:28:08 +01:00
Cargo.toml Remove std_detect_file_io and std_detect_dlsym_getauxval features 2026-01-08 14:50:12 +00:00