@@ -6,7 +6,7 @@ use crate::sys::weak::dlsym;
6
6
#[ cfg( any( target_os = "solaris" , target_os = "illumos" , target_os = "nto" , ) ) ]
7
7
use crate :: sys:: weak:: weak;
8
8
use crate :: sys:: { os, stack_overflow} ;
9
- use crate :: time:: Duration ;
9
+ use crate :: time:: { Duration , Instant } ;
10
10
use crate :: { cmp, io, ptr} ;
11
11
#[ cfg( not( any(
12
12
target_os = "l4re" ,
@@ -296,27 +296,7 @@ impl Thread {
296
296
}
297
297
}
298
298
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
320
300
#[ cfg( any(
321
301
target_os = "freebsd" ,
322
302
target_os = "netbsd" ,
@@ -352,6 +332,27 @@ impl Thread {
352
332
}
353
333
}
354
334
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
+
355
356
pub fn join ( self ) {
356
357
let id = self . into_id ( ) ;
357
358
let ret = unsafe { libc:: pthread_join ( id, ptr:: null_mut ( ) ) } ;
0 commit comments