about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-07-07 09:35:56 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-07-21 13:23:34 -0400
commitcbdc52e9867ce550c2f8a22613106f65cf54a7ef (patch)
tree31b30ede5a7bd15cc59340b230bcfbac71bdcc7b
parent4e51763e6428580f2b3275cd7076492376801a1e (diff)
downloadrust-cbdc52e9867ce550c2f8a22613106f65cf54a7ef.tar.gz
rust-cbdc52e9867ce550c2f8a22613106f65cf54a7ef.zip
Expand a bit on thread::park spurious wakeups
Fixes #26475
-rw-r--r--src/libstd/thread/mod.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index dbb7d3233bc..3299c848ba7 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -508,9 +508,25 @@ pub fn sleep(dur: Duration) {
     imp::Thread::sleep(dur)
 }
 
-/// Blocks unless or until the current thread's token is made available (may wake spuriously).
+/// Blocks unless or until the current thread's token is made available.
 ///
-/// See the module doc for more detail.
+/// Every thread is equipped with some basic low-level blocking support, via
+/// the `park()` function and the [`unpark()`][unpark] method. These can be
+/// used as a more CPU-efficient implementation of a spinlock.
+///
+/// [unpark]: struct.Thread.html#method.unpark
+///
+/// The API is typically used by acquiring a handle to the current thread,
+/// placing that handle in a shared data structure so that other threads can
+/// find it, and then parking (in a loop with a check for the token actually
+/// being acquired).
+///
+/// A call to `park` does not guarantee that the thread will remain parked
+/// forever, and callers should be prepared for this possibility.
+///
+/// See the [module documentation][thread] for more detail.
+///
+/// [thread]: index.html
 //
 // The implementation currently uses the trivial strategy of a Mutex+Condvar
 // with wakeup flag, which does not actually allow spurious wakeups. In the