time: update sleep documentation to reflect maximum allowed duration (#7302)

This commit is contained in:
Till Rohrmann 2025-05-04 18:13:07 +02:00 committed by GitHub
parent a0af02a396
commit 48ca254d92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 7 deletions

View File

@ -76,8 +76,6 @@ 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

View File

@ -259,13 +259,10 @@ async fn reset_after_firing() {
.poll(&mut Context::from_waker(noop_waker_ref())));
}
const NUM_LEVELS: usize = 6;
const MAX_DURATION: u64 = (1 << (6 * NUM_LEVELS)) - 1;
#[tokio::test]
async fn exactly_max() {
time::pause();
time::sleep(ms(MAX_DURATION)).await;
time::sleep(Duration::MAX).await;
}
#[tokio::test]
@ -285,7 +282,7 @@ async fn issue_5183() {
#[tokio::test]
async fn no_out_of_bounds_close_to_max() {
time::pause();
time::sleep(ms(MAX_DURATION - 1)).await;
time::sleep(Duration::MAX - Duration::from_millis(1)).await;
}
fn ms(n: u64) -> Duration {