Skip to content

Commit 05f1cad

Browse files
committed
removes the specialization for windows OS
It is not working and I can not figure out why. Since I am not familiar with developing on windows I might not be the best person to work on this. The work removed in this commit might be a useful jumping off point for anyone else however.
1 parent 947899e commit 05f1cad

File tree

4 files changed

+2
-28
lines changed

4 files changed

+2
-28
lines changed

library/std/src/sys/pal/unix/thread.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ impl Thread {
357357

358358
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
359359
pub fn sleep_until(deadline: crate::time::Instant) {
360-
use super::time::Timespec;
361360
use core::mem::MaybeUninit;
362361

362+
use super::time::Timespec;
363+
363364
let Timespec { tv_sec, tv_nsec } = deadline.into_inner().into_timespec();
364365
let nanos = (tv_sec as u64).saturating_mul(1_000_000_000).saturating_add(tv_nsec.0 as u64);
365366

library/std/src/sys/pal/windows/thread.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,6 @@ impl Thread {
116116
}
117117
}
118118

119-
pub fn sleep_until(deadline: Instant) {
120-
fn high_precision_sleep(deadline: Instant) -> Result<(), ()> {
121-
let timer = WaitableTimer::high_resolution()?;
122-
timer.set_deadline(deadline.into_inner())?;
123-
timer.wait()
124-
}
125-
// Attempt to use high-precision sleep (Windows 10, version 1803+).
126-
// On error fallback to the standard `Sleep` function.
127-
// Also preserves the zero duration behaviour of `Sleep`.
128-
if high_precision_sleep(deadline).is_ok() {
129-
return;
130-
}
131-
132-
let now = Instant::now();
133-
if let Some(dur) = deadline.checked_duration_since(now) {
134-
unsafe { c::Sleep(super::dur2timeout(dur)) }
135-
};
136-
}
137-
138119
pub fn handle(&self) -> &Handle {
139120
&self.handle
140121
}

library/std/src/sys/pal/windows/time.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,6 @@ impl WaitableTimer {
248248
let result = unsafe { c::SetWaitableTimer(self.handle, &time, 0, None, null(), c::FALSE) };
249249
if result != 0 { Ok(()) } else { Err(()) }
250250
}
251-
pub fn set_deadline(&self, deadline: Instant) -> Result<(), ()> {
252-
// Convert the Instant to a format similar to FILETIME.
253-
let time = checked_dur2intervals(&deadline.t).ok_or(())?;
254-
let result = unsafe { c::SetWaitableTimer(self.handle, &time, 0, None, null(), c::FALSE) };
255-
if result != 0 { Ok(()) } else { Err(()) }
256-
}
257251
pub fn wait(&self) -> Result<(), ()> {
258252
let result = unsafe { c::WaitForSingleObject(self.handle, c::INFINITE) };
259253
if result != c::WAIT_FAILED { Ok(()) } else { Err(()) }

library/std/src/thread/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,14 +896,12 @@ pub fn sleep(dur: Duration) {
896896
/// | Illumos | [clock_nanosleep] (Monotonic Clock)] |
897897
/// | Darwin | [mach_wait_until] |
898898
/// | WASI | [subscription_clock] |
899-
/// | Windows | [SetWaitableTimer] |
900899
/// | Other | `sleep_until` uses [`sleep`] and does not issue a syscall itself |
901900
///
902901
/// [currently]: crate::io#platform-specific-behavior
903902
/// [clock_nanosleep]: https://linux.die.net/man/3/clock_nanosleep
904903
/// [subscription_clock]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-subscription_clock-record
905904
/// [mach_wait_until]: https://developer.apple.com/library/archive/technotes/tn2169/_index.html
906-
/// [SetWaitableTimer]: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-setwaitabletimer
907905
///
908906
/// **Disclaimer:** These system calls might change over time.
909907
///

0 commit comments

Comments
 (0)