about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-06-28 16:05:14 +0200
committerGitHub <noreply@github.com>2016-06-28 16:05:14 +0200
commit5d6b41f3bcccc48cb2f6a50c1d446d7f619ddd3e (patch)
tree503155b916ffdeb88628aaa5f4ded28a8b4f3db4 /src/libstd/thread
parent47ef866f43ae828a675e3a590fa7abee6d8d1595 (diff)
parenta7b9e5441bed52ab89e0212816fdd09ea9a29d36 (diff)
downloadrust-5d6b41f3bcccc48cb2f6a50c1d446d7f619ddd3e.tar.gz
rust-5d6b41f3bcccc48cb2f6a50c1d446d7f619ddd3e.zip
Rollup merge of #34406 - frewsxcv:sleep-ex, r=alexcrichton
Add example for `std::thread::sleep`.

None
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index 3bee878de35..e9736fea7b3 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -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)