Skip to content

Commit

Permalink
Rollup merge of rust-lang#34406 - frewsxcv:sleep-ex, r=alexcrichton
Browse files Browse the repository at this point in the history
Add example for `std::thread::sleep`.

None
  • Loading branch information
GuillaumeGomez authored Jun 28, 2016
2 parents 47ef866 + a7b9e54 commit 5d6b41f
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 @@ -394,6 +394,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 5d6b41f

Please sign in to comment.