Skip to content

Commit

Permalink
doc: sync interval.rs and time/mod.rs docs (#3533)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkmik committed Feb 22, 2021
1 parent 52457dc commit 7de18af
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tokio/src/time/mod.rs
Expand Up @@ -56,10 +56,10 @@
//!
//! A simple example using [`interval`] to execute a task every two seconds.
//!
//! The difference between [`interval`] and [`sleep`] is that an
//! [`interval`] measures the time since the last tick, which means that
//! `.tick().await` may wait for a shorter time than the duration specified
//! for the interval if some time has passed between calls to `.tick().await`.
//! The difference between [`interval`] and [`sleep`] is that an [`interval`]
//! measures the time since the last tick, which means that `.tick().await`
//! may wait for a shorter time than the duration specified for the interval
//! if some time has passed between calls to `.tick().await`.
//!
//! If the tick in the example below was replaced with [`sleep`], the task
//! would only be executed once every three seconds, and not every two
Expand All @@ -75,11 +75,9 @@
//!
//! #[tokio::main]
//! async fn main() {
//! let interval = time::interval(time::Duration::from_secs(2));
//! tokio::pin!(interval);
//!
//! let mut interval = time::interval(time::Duration::from_secs(2));
//! for _i in 0..5 {
//! interval.as_mut().tick().await;
//! interval.tick().await;
//! task_that_takes_a_second().await;
//! }
//! }
Expand Down

0 comments on commit 7de18af

Please sign in to comment.