diff options
author | Juan Alvarez <j@yabit.io> | 2020-10-01 02:24:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 09:24:33 +0200 |
commit | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 (patch) | |
tree | 66f0b4c089729616b57bbb69b0a6351b45a0c898 /tokio/src/time/delay_queue.rs | |
parent | 971ed2c6df9cb3bf3543a9c780662a0b4d1a8d40 (diff) |
time: introduce `sleep` and `sleep_until` functions (#2826)
Diffstat (limited to 'tokio/src/time/delay_queue.rs')
-rw-r--r-- | tokio/src/time/delay_queue.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/time/delay_queue.rs b/tokio/src/time/delay_queue.rs index 6f755eba..910f75fb 100644 --- a/tokio/src/time/delay_queue.rs +++ b/tokio/src/time/delay_queue.rs @@ -5,7 +5,7 @@ //! [`DelayQueue`]: struct@DelayQueue use crate::time::wheel::{self, Wheel}; -use crate::time::{delay_until, Delay, Duration, Error, Instant}; +use crate::time::{sleep_until, Delay, Duration, Error, Instant}; use slab::Slab; use std::cmp; @@ -51,7 +51,7 @@ use std::task::{self, Poll}; /// # Implementation /// /// The [`DelayQueue`] is backed by a separate instance of the same timer wheel used internally by -/// Tokio's standalone timer utilities such as [`delay_for`]. Because of this, it offers the same +/// Tokio's standalone timer utilities such as [`sleep`]. Because of this, it offers the same /// performance and scalability benefits. /// /// State associated with each entry is stored in a [`slab`]. This amortizes the cost of allocation, @@ -118,7 +118,7 @@ use std::task::{self, Poll}; /// [`poll_expired`]: method@Self::poll_expired /// [`Stream::poll_expired`]: method@Self::poll_expired /// [`DelayQueue`]: struct@DelayQueue -/// [`delay_for`]: fn@super::delay_for +/// [`sleep`]: fn@super::sleep /// [`slab`]: slab /// [`capacity`]: method@Self::capacity /// [`reserve`]: method@Self::reserve @@ -330,7 +330,7 @@ impl<T> DelayQueue<T> { if let Some(ref mut delay) = &mut self.delay { delay.reset(delay_time); } else { - self.delay = Some(delay_until(delay_time)); + self.delay = Some(sleep_until(delay_time)); } } @@ -734,7 +734,7 @@ impl<T> DelayQueue<T> { // We poll the wheel to get the next value out before finding the next deadline. let wheel_idx = self.wheel.poll(&mut self.poll, &mut self.slab); - self.delay = self.next_deadline().map(delay_until); + self.delay = self.next_deadline().map(sleep_until); if let Some(idx) = wheel_idx { return Poll::Ready(Some(Ok(idx))); |