We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c2bbfea commit 3712bb6Copy full SHA for 3712bb6
src/libstd/sync/once.rs
@@ -469,6 +469,10 @@ fn wait(state_and_queue: &AtomicUsize, current_state: usize) {
469
// dangling reference). Guard against spurious wakeups by reparking
470
// ourselves until we are signaled.
471
while !node.signaled.load(Ordering::Acquire) {
472
+ // If the managing thread happens to signal and unpark us before we can
473
+ // park ourselves, the result could be this thread never gets unparked.
474
+ // Luckily `park` comes with the guarantee that if it got an `unpark`
475
+ // just before on an unparked thread is does not park.
476
thread::park();
477
}
478
0 commit comments