From 39d51d04e706dee462ac4a17508ed87eb52e7715 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Aug 2025 18:12:36 +0200 Subject: thread parking: fix docs and examples --- library/std/src/sys/sync/once/queue.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'library/std/src/sys/sync') diff --git a/library/std/src/sys/sync/once/queue.rs b/library/std/src/sys/sync/once/queue.rs index 49e15d65f25..17d99cdb385 100644 --- a/library/std/src/sys/sync/once/queue.rs +++ b/library/std/src/sys/sync/once/queue.rs @@ -276,7 +276,9 @@ fn wait( // 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 it does not park. + // an `unpark` just before on an unparked thread it does not park. Crucially, we know + // the `unpark` must have happened between the `compare_exchange_weak` above and here, + // and there's no other `park` in that code that could steal our token. // SAFETY: we retrieved this handle on the current thread above. unsafe { node.thread.park() } } -- cgit 1.4.1-3-g733a5