about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-29 15:45:45 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-29 15:45:45 -0700
commit0eaa811f4c66f933d40cf360bb7ffbc3eadeeaad (patch)
treefe54821bf5067a04aab1b222fe5703ab495429dc /src/libstd/sync
parentb0f920ace428215ebc752e77cbc904a8032895e8 (diff)
parented4c05e5971ad48d8df08e83360e7ddc0871772a (diff)
downloadrust-0eaa811f4c66f933d40cf360bb7ffbc3eadeeaad.tar.gz
rust-0eaa811f4c66f933d40cf360bb7ffbc3eadeeaad.zip
rollup merge of #24908: inrustwetrust/once_memory_ordering
`call_once` guarantees that there is a happens-before relationship between its closure and code following it via the sequentially consistent atomic store/loads of `self.cnt`.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/once.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs
index 2ce974c1271..2d712369228 100644
--- a/src/libstd/sync/once.rs
+++ b/src/libstd/sync/once.rs
@@ -59,7 +59,11 @@ impl Once {
     /// routine is currently running.
     ///
     /// When this function returns, it is guaranteed that some initialization
-    /// has run and completed (it may not be the closure specified).
+    /// has run and completed (it may not be the closure specified). It is also
+    /// guaranteed that any memory writes performed by the executed closure can
+    /// be reliably observed by other tasks at this point (there is a
+    /// happens-before relation between the closure and code executing after the
+    /// return).
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn call_once<F>(&'static self, f: F) where F: FnOnce() {
         // Optimize common path: load is much cheaper than fetch_add.