@@ -897,8 +897,33 @@ pub fn sleep(dur: Duration) {
897
897
///
898
898
/// # Platform-specific behavior
899
899
///
900
- /// This function uses [`sleep`] internally, see its platform-specific behavior.
901
- ///
900
+ /// In most cases this function will call an OS specific function. Where that
901
+ /// is not supported [`sleep`] is used. Those platforms are referred to as other
902
+ /// in the table below.
903
+ ///
904
+ /// # Underlying System calls
905
+ ///
906
+ /// The following system calls are [currently] being used:
907
+ ///
908
+ /// | Platform | System call |
909
+ /// |-----------|----------------------------------------------------------------------|
910
+ /// | Linux | [clock_nanosleep] (Monotonic clock) |
911
+ /// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock)] |
912
+ /// | Android | [clock_nanosleep] (Monotonic Clock)] |
913
+ /// | Solaris | [clock_nanosleep] (Monotonic Clock)] |
914
+ /// | Illumos | [clock_nanosleep] (Monotonic Clock)] |
915
+ /// | Dragonfly | [clock_nanosleep] (Monotonic Clock)] |
916
+ /// | Hurd | [clock_nanosleep] (Monotonic Clock)] |
917
+ /// | Fuchsia | [clock_nanosleep] (Monotonic Clock)] |
918
+ /// | Vxworks | [clock_nanosleep] (Monotonic Clock)] |
919
+ /// | Other | `sleep_until` uses [`sleep`] and does not issue a syscall itself |
920
+ ///
921
+ /// [currently]: crate::io#platform-specific-behavior
922
+ /// [clock_nanosleep]: https://linux.die.net/man/3/clock_nanosleep
923
+ /// [subscription_clock]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-subscription_clock-record
924
+ /// [mach_wait_until]: https://developer.apple.com/library/archive/technotes/tn2169/_index.html
925
+ ///
926
+ /// **Disclaimer:** These system calls might change over time.
902
927
///
903
928
/// # Examples
904
929
///
@@ -923,9 +948,9 @@ pub fn sleep(dur: Duration) {
923
948
/// }
924
949
/// ```
925
950
///
926
- /// A slow api we must not call too fast and which takes a few
951
+ /// A slow API we must not call too fast and which takes a few
927
952
/// tries before succeeding. By using `sleep_until` the time the
928
- /// api call takes does not influence when we retry or when we give up
953
+ /// API call takes does not influence when we retry or when we give up
929
954
///
930
955
/// ```no_run
931
956
/// #![feature(thread_sleep_until)]
@@ -960,11 +985,7 @@ pub fn sleep(dur: Duration) {
960
985
/// ```
961
986
#[ unstable( feature = "thread_sleep_until" , issue = "113752" ) ]
962
987
pub fn sleep_until ( deadline : Instant ) {
963
- let now = Instant :: now ( ) ;
964
-
965
- if let Some ( delay) = deadline. checked_duration_since ( now) {
966
- sleep ( delay) ;
967
- }
988
+ imp:: Thread :: sleep_until ( deadline)
968
989
}
969
990
970
991
/// Used to ensure that `park` and `park_timeout` do not unwind, as that can
0 commit comments