From 9d0c0dd22cfa028af63798671c781b1fd83562e2 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 11 Nov 2020 20:31:22 +0100 Subject: time: document maximum sleep duration (#3126) --- tokio/src/time/sleep.rs | 2 ++ tokio/tests/time_sleep.rs | 1 + 2 files changed, 3 insertions(+) (limited to 'tokio') diff --git a/tokio/src/time/sleep.rs b/tokio/src/time/sleep.rs index d3234a18..2bd4eb1a 100644 --- a/tokio/src/time/sleep.rs +++ b/tokio/src/time/sleep.rs @@ -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 diff --git a/tokio/tests/time_sleep.rs b/tokio/tests/time_sleep.rs index 87d69dee..955d833b 100644 --- a/tokio/tests/time_sleep.rs +++ b/tokio/tests/time_sleep.rs @@ -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; } -- cgit v1.2.3