@@ -6,7 +6,7 @@ use crate::sys::weak::dlsym;
66#[ cfg( any( target_os = "solaris" , target_os = "illumos" , target_os = "nto" , ) ) ]
77use crate :: sys:: weak:: weak;
88use crate :: sys:: { os, stack_overflow} ;
9- use crate :: time:: Duration ;
9+ use crate :: time:: { Duration , Instant } ;
1010use crate :: { cmp, io, ptr} ;
1111#[ cfg( not( any(
1212 target_os = "l4re" ,
@@ -296,27 +296,7 @@ impl Thread {
296296 }
297297 }
298298
299- #[ cfg( not( any(
300- target_os = "freebsd" ,
301- target_os = "netbsd" ,
302- target_os = "linux" ,
303- target_os = "android" ,
304- target_os = "solaris" ,
305- target_os = "illumos" ,
306- target_os = "dragonfly" ,
307- target_os = "hurd" ,
308- target_os = "fuchsia" ,
309- target_os = "vxworks" ,
310- ) ) ) ]
311- pub fn sleep_until ( deadline : Instant ) {
312- let now = Instant :: now ( ) ;
313-
314- if let Some ( delay) = deadline. checked_duration_since ( now) {
315- sleep ( delay) ;
316- }
317- }
318-
319- // Note depends on clock_nanosleep (not supported on os's by apple)
299+ // Any unix that has clock_nanosleep
320300 #[ cfg( any(
321301 target_os = "freebsd" ,
322302 target_os = "netbsd" ,
@@ -352,6 +332,27 @@ impl Thread {
352332 }
353333 }
354334
335+ // Any unix that does not have clock_nanosleep
336+ #[ cfg( not( any(
337+ target_os = "freebsd" ,
338+ target_os = "netbsd" ,
339+ target_os = "linux" ,
340+ target_os = "android" ,
341+ target_os = "solaris" ,
342+ target_os = "illumos" ,
343+ target_os = "dragonfly" ,
344+ target_os = "hurd" ,
345+ target_os = "fuchsia" ,
346+ target_os = "vxworks" ,
347+ ) ) ) ]
348+ pub fn sleep_until ( deadline : Instant ) {
349+ let now = Instant :: now ( ) ;
350+
351+ if let Some ( delay) = deadline. checked_duration_since ( now) {
352+ Self :: sleep ( delay) ;
353+ }
354+ }
355+
355356 pub fn join ( self ) {
356357 let id = self . into_id ( ) ;
357358 let ret = unsafe { libc:: pthread_join ( id, ptr:: null_mut ( ) ) } ;
0 commit comments