time: document maximum sleep duration (#3126)

This commit is contained in:
Alice Ryhl
2020-11-11 11:31:22 -08:00
committed by GitHub
parent 6d5423f3e9
commit 9d0c0dd22c
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -31,6 +31,8 @@ pub fn sleep_until(deadline: Instant) -> Sleep {
///
/// To run something regularly on a schedule, see [`interval`].
///
/// The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).
///
/// # Cancellation
///
/// Canceling a sleep instance is done by dropping the returned future. No additional
+1
View File
@@ -182,6 +182,7 @@ const MAX_DURATION: u64 = (1 << (6 * NUM_LEVELS)) - 1;
#[tokio::test]
async fn exactly_max() {
// TODO: this should not panic but `time::ms()` is acting up
// If fixed, make sure to update documentation on `time::sleep` too.
time::sleep(ms(MAX_DURATION)).await;
}