about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPaul Dicker <pitdicker@gmail.com>2019-10-25 10:01:27 +0200
committerPaul Dicker <pitdicker@gmail.com>2019-10-25 10:01:27 +0200
commit3712bb68c4f76161b54dcade7c1497b3ffc32e11 (patch)
treedd9c3f390a2110af06a7cbcf0cc66c4ce21536b1 /src/libstd
parentc2bbfeadcce08a4b8ce02b66906ecc542cc9df39 (diff)
downloadrust-3712bb68c4f76161b54dcade7c1497b3ffc32e11.tar.gz
rust-3712bb68c4f76161b54dcade7c1497b3ffc32e11.zip
Mention park guarantee
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sync/once.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs
index c135471e2f2..bdb941cff52 100644
--- a/src/libstd/sync/once.rs
+++ b/src/libstd/sync/once.rs
@@ -469,6 +469,10 @@ fn wait(state_and_queue: &AtomicUsize, current_state: usize) {
     // dangling reference). Guard against spurious wakeups by reparking
     // ourselves until we are signaled.
     while !node.signaled.load(Ordering::Acquire) {
+        // If the managing thread happens to signal and unpark us before we can
+        // park ourselves, the result could be this thread never gets unparked.
+        // Luckily `park` comes with the guarantee that if it got an `unpark`
+        // just before on an unparked thread is does not park.
         thread::park();
     }
 }