Skip to content

Commit 48ca254

Browse files
authored
time: update sleep documentation to reflect maximum allowed duration (#7302)
1 parent a0af02a commit 48ca254

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

tokio/src/time/sleep.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ pub fn sleep_until(deadline: Instant) -> Sleep {
7676
///
7777
/// To run something regularly on a schedule, see [`interval`].
7878
///
79-
/// The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).
80-
///
8179
/// # Cancellation
8280
///
8381
/// Canceling a sleep instance is done by dropping the returned future. No additional

tokio/tests/time_sleep.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,10 @@ async fn reset_after_firing() {
259259
.poll(&mut Context::from_waker(noop_waker_ref())));
260260
}
261261

262-
const NUM_LEVELS: usize = 6;
263-
const MAX_DURATION: u64 = (1 << (6 * NUM_LEVELS)) - 1;
264-
265262
#[tokio::test]
266263
async fn exactly_max() {
267264
time::pause();
268-
time::sleep(ms(MAX_DURATION)).await;
265+
time::sleep(Duration::MAX).await;
269266
}
270267

271268
#[tokio::test]
@@ -285,7 +282,7 @@ async fn issue_5183() {
285282
#[tokio::test]
286283
async fn no_out_of_bounds_close_to_max() {
287284
time::pause();
288-
time::sleep(ms(MAX_DURATION - 1)).await;
285+
time::sleep(Duration::MAX - Duration::from_millis(1)).await;
289286
}
290287

291288
fn ms(n: u64) -> Duration {

0 commit comments

Comments
 (0)