Skip to content

Commit

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

None
  • Loading branch information
GuillaumeGomez authored Jun 25, 2016
2 parents 6b949e9 + bbc33ac commit dfbf619
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 dfbf619

Please sign in to comment.