Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Sync interval.rs and time/mod.rs docs #3533

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions tokio/src/time/mod.rs
Original file line number Diff line number Diff line change
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