Skip to content

Commit b84f018

Browse files
inrustwetruststeveklabnik
authored andcommitted
Clarify Once::call_once memory ordering guarantees in docs
1 parent 7a0af01 commit b84f018

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libstd/sync/once.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ impl Once {
5959
/// routine is currently running.
6060
///
6161
/// When this function returns, it is guaranteed that some initialization
62-
/// has run and completed (it may not be the closure specified).
62+
/// has run and completed (it may not be the closure specified). It is also
63+
/// guaranteed that any memory writes performed by the executed closure can
64+
/// be reliably observed by other tasks at this point (there is a
65+
/// happens-before relation between the closure and code executing after the
66+
/// return).
6367
#[stable(feature = "rust1", since = "1.0.0")]
6468
pub fn call_once<F>(&'static self, f: F) where F: FnOnce() {
6569
// Optimize common path: load is much cheaper than fetch_add.

0 commit comments

Comments
 (0)