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 23, 2016
1 parent fe96928 commit bbc33ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
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
///
/// ```
/// 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 bbc33ac

Please sign in to comment.