Skip to content

Commit

Permalink
Add example for std::thread::sleep.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jun 27, 2016
1 parent fe96928 commit a7b9e54
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libstd/thread/mod.rs
Expand Up @@ -379,6 +379,19 @@ pub fn sleep_ms(ms: u32) {
/// signal being received or a spurious wakeup. Platforms which do not support
/// nanosecond precision for sleeping will have `dur` rounded up to the nearest
/// granularity of time they can sleep for.
///
/// # Examples
///
/// ```rust,no_run
/// use std::{thread, time};
///
/// let ten_millis = time::Duration::from_millis(10);
/// let now = time::Instant::now();
///
/// thread::sleep(ten_millis);
///
/// assert!(now.elapsed() >= ten_millis);
/// ```
#[stable(feature = "thread_sleep", since = "1.4.0")]
pub fn sleep(dur: Duration) {
imp::Thread::sleep(dur)
Expand Down

0 comments on commit a7b9e54

Please sign in to comment.