File tree Expand file tree Collapse file tree 8 files changed +39
-70
lines changed Expand file tree Collapse file tree 8 files changed +39
-70
lines changed Original file line number Diff line number Diff line change @@ -86,14 +86,6 @@ impl Thread {
86
86
}
87
87
}
88
88
89
- pub fn sleep_until ( deadline : Instant ) {
90
- let now = Instant :: now ( ) ;
91
-
92
- if let Some ( delay) = deadline. checked_duration_since ( now) {
93
- sleep ( delay) ;
94
- }
95
- }
96
-
97
89
pub fn join ( self ) {
98
90
unsafe {
99
91
let _ = hermit_abi:: join ( self . tid ) ;
Original file line number Diff line number Diff line change @@ -205,14 +205,6 @@ impl Thread {
205
205
}
206
206
}
207
207
208
- pub fn sleep_until ( deadline : Instant ) {
209
- let now = Instant :: now ( ) ;
210
-
211
- if let Some ( delay) = deadline. checked_duration_since ( now) {
212
- sleep ( delay) ;
213
- }
214
- }
215
-
216
208
pub fn join ( self ) {
217
209
// Safety: `ThreadInner` is alive at this point
218
210
let inner = unsafe { self . p_inner . as_ref ( ) } ;
Original file line number Diff line number Diff line change @@ -132,14 +132,6 @@ impl Thread {
132
132
usercalls:: wait_timeout ( 0 , dur, || true ) ;
133
133
}
134
134
135
- pub fn sleep_until ( deadline : Instant ) {
136
- let now = Instant :: now ( ) ;
137
-
138
- if let Some ( delay) = deadline. checked_duration_since ( now) {
139
- sleep ( delay) ;
140
- }
141
- }
142
-
143
135
pub fn join ( self ) {
144
136
self . 0 . wait ( ) ;
145
137
}
Original file line number Diff line number Diff line change @@ -296,27 +296,6 @@ impl Thread {
296
296
}
297
297
}
298
298
299
- #[ cfg( not( any(
300
- target_vendor = "apple" ,
301
- target_os = "freebsd" ,
302
- target_os = "netbsd" ,
303
- target_os = "linux" ,
304
- target_os = "android" ,
305
- target_os = "solaris" ,
306
- target_os = "illumos" ,
307
- target_os = "dragonfly" ,
308
- target_os = "hurd" ,
309
- target_os = "fuchsia" ,
310
- target_os = "vxworks" ,
311
- ) ) ) ]
312
- pub fn sleep_until ( deadline : Instant ) {
313
- let now = Instant :: now ( ) ;
314
-
315
- if let Some ( delay) = deadline. checked_duration_since ( now) {
316
- sleep ( delay) ;
317
- }
318
- }
319
-
320
299
// Note depends on clock_nanosleep (not supported on os's by apple)
321
300
#[ cfg( any(
322
301
target_os = "freebsd" ,
Original file line number Diff line number Diff line change @@ -171,14 +171,6 @@ impl Thread {
171
171
}
172
172
}
173
173
174
- pub fn sleep_until ( deadline : Instant ) {
175
- let now = Instant :: now ( ) ;
176
-
177
- if let Some ( delay) = deadline. checked_duration_since ( now) {
178
- sleep ( delay) ;
179
- }
180
- }
181
-
182
174
pub fn join ( self ) {
183
175
cfg_if:: cfg_if! {
184
176
if #[ cfg( target_feature = "atomics" ) ] {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use crate::os::windows::io::{AsRawHandle, HandleOrNull};
8
8
use crate :: sys:: handle:: Handle ;
9
9
use crate :: sys:: { c, stack_overflow} ;
10
10
use crate :: sys_common:: FromInner ;
11
- use crate :: time:: { Duration , Instant } ;
11
+ use crate :: time:: Duration ;
12
12
use crate :: { io, ptr} ;
13
13
14
14
pub const DEFAULT_MIN_STACK_SIZE : usize = 2 * 1024 * 1024 ;
@@ -106,14 +106,6 @@ impl Thread {
106
106
}
107
107
}
108
108
109
- pub fn sleep_until ( deadline : Instant ) {
110
- let now = Instant :: now ( ) ;
111
-
112
- if let Some ( delay) = deadline. checked_duration_since ( now) {
113
- Self :: sleep ( delay) ;
114
- }
115
- }
116
-
117
109
pub fn handle ( & self ) -> & Handle {
118
110
& self . handle
119
111
}
Original file line number Diff line number Diff line change @@ -128,14 +128,6 @@ impl Thread {
128
128
}
129
129
}
130
130
131
- pub fn sleep_until ( deadline : Instant ) {
132
- let now = Instant :: now ( ) ;
133
-
134
- if let Some ( delay) = deadline. checked_duration_since ( now) {
135
- sleep ( delay) ;
136
- }
137
- }
138
-
139
131
pub fn join ( self ) {
140
132
join_thread ( self . tid ) . unwrap ( ) ;
141
133
}
Original file line number Diff line number Diff line change @@ -985,6 +985,44 @@ pub fn sleep(dur: Duration) {
985
985
/// ```
986
986
#[ unstable( feature = "thread_sleep_until" , issue = "113752" ) ]
987
987
pub fn sleep_until ( deadline : Instant ) {
988
+ impl_sleep_until ( deadline)
989
+ }
990
+
991
+ #[ cfg( not( any(
992
+ target_os = "freebsd" ,
993
+ target_os = "netbsd" ,
994
+ target_os = "linux" ,
995
+ target_os = "android" ,
996
+ target_os = "solaris" ,
997
+ target_os = "illumos" ,
998
+ target_os = "dragonfly" ,
999
+ target_os = "hurd" ,
1000
+ target_os = "fuchsia" ,
1001
+ target_os = "vxworks" ,
1002
+ ) ) ) ]
1003
+ #[ inline]
1004
+ fn impl_sleep_until ( deadline : Instant ) {
1005
+ let now = Instant :: now ( ) ;
1006
+
1007
+ if let Some ( delay) = deadline. checked_duration_since ( now) {
1008
+ sleep ( delay) ;
1009
+ }
1010
+ }
1011
+
1012
+ #[ cfg( any(
1013
+ target_os = "freebsd" ,
1014
+ target_os = "netbsd" ,
1015
+ target_os = "linux" ,
1016
+ target_os = "android" ,
1017
+ target_os = "solaris" ,
1018
+ target_os = "illumos" ,
1019
+ target_os = "dragonfly" ,
1020
+ target_os = "hurd" ,
1021
+ target_os = "fuchsia" ,
1022
+ target_os = "vxworks" ,
1023
+ ) ) ]
1024
+ #[ inline]
1025
+ fn impl_sleep_until ( deadline : Instant ) {
988
1026
imp:: Thread :: sleep_until ( deadline)
989
1027
}
990
1028
You can’t perform that action at this time.
0 commit comments