Skip to content

Commit 21dfd24

Browse files
committed
Auto merge of #26856 - steveklabnik:gh26475, r=alexcrichton
Fixes #26475 I'm not sure this is enough, really, but I'm not totally clear on what specific information would be valuable here. In the original issue, the Java page was pretty decent, but now I can't think of a different way to word it, and copying their prose is of course not acceptable. thoughts @alexcrichton @aturon @aidanhs ?
2 parents 5dbddfb + cbdc52e commit 21dfd24

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/libstd/thread/mod.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,25 @@ pub fn sleep(dur: Duration) {
508508
imp::Thread::sleep(dur)
509509
}
510510

511-
/// Blocks unless or until the current thread's token is made available (may wake spuriously).
511+
/// Blocks unless or until the current thread's token is made available.
512512
///
513-
/// See the module doc for more detail.
513+
/// Every thread is equipped with some basic low-level blocking support, via
514+
/// the `park()` function and the [`unpark()`][unpark] method. These can be
515+
/// used as a more CPU-efficient implementation of a spinlock.
516+
///
517+
/// [unpark]: struct.Thread.html#method.unpark
518+
///
519+
/// The API is typically used by acquiring a handle to the current thread,
520+
/// placing that handle in a shared data structure so that other threads can
521+
/// find it, and then parking (in a loop with a check for the token actually
522+
/// being acquired).
523+
///
524+
/// A call to `park` does not guarantee that the thread will remain parked
525+
/// forever, and callers should be prepared for this possibility.
526+
///
527+
/// See the [module documentation][thread] for more detail.
528+
///
529+
/// [thread]: index.html
514530
//
515531
// The implementation currently uses the trivial strategy of a Mutex+Condvar
516532
// with wakeup flag, which does not actually allow spurious wakeups. In the

0 commit comments

Comments
 (0)