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 {
8686 }
8787 }
8888
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-
9789 pub fn join ( self ) {
9890 unsafe {
9991 let _ = hermit_abi:: join ( self . tid ) ;
Original file line number Diff line number Diff line change @@ -205,14 +205,6 @@ impl Thread {
205205 }
206206 }
207207
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-
216208 pub fn join ( self ) {
217209 // Safety: `ThreadInner` is alive at this point
218210 let inner = unsafe { self . p_inner . as_ref ( ) } ;
Original file line number Diff line number Diff line change @@ -132,14 +132,6 @@ impl Thread {
132132 usercalls:: wait_timeout ( 0 , dur, || true ) ;
133133 }
134134
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-
143135 pub fn join ( self ) {
144136 self . 0 . wait ( ) ;
145137 }
Original file line number Diff line number Diff line change @@ -296,27 +296,6 @@ impl Thread {
296296 }
297297 }
298298
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-
320299 // Note depends on clock_nanosleep (not supported on os's by apple)
321300 #[ cfg( any(
322301 target_os = "freebsd" ,
Original file line number Diff line number Diff line change @@ -171,14 +171,6 @@ impl Thread {
171171 }
172172 }
173173
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-
182174 pub fn join ( self ) {
183175 cfg_if:: cfg_if! {
184176 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};
88use crate :: sys:: handle:: Handle ;
99use crate :: sys:: { c, stack_overflow} ;
1010use crate :: sys_common:: FromInner ;
11- use crate :: time:: { Duration , Instant } ;
11+ use crate :: time:: Duration ;
1212use crate :: { io, ptr} ;
1313
1414pub const DEFAULT_MIN_STACK_SIZE : usize = 2 * 1024 * 1024 ;
@@ -106,14 +106,6 @@ impl Thread {
106106 }
107107 }
108108
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-
117109 pub fn handle ( & self ) -> & Handle {
118110 & self . handle
119111 }
Original file line number Diff line number Diff line change @@ -128,14 +128,6 @@ impl Thread {
128128 }
129129 }
130130
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-
139131 pub fn join ( self ) {
140132 join_thread ( self . tid ) . unwrap ( ) ;
141133 }
Original file line number Diff line number Diff line change @@ -985,6 +985,44 @@ pub fn sleep(dur: Duration) {
985985/// ```
986986#[ unstable( feature = "thread_sleep_until" , issue = "113752" ) ]
987987pub 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 ) {
9881026 imp:: Thread :: sleep_until ( deadline)
9891027}
9901028
You can’t perform that action at this time.
0 commit comments