mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
time: update sleep
documentation to reflect maximum allowed duration (#7302)
This commit is contained in:
parent
a0af02a396
commit
48ca254d92
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user