mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 10:05:06 +03:00
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`.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user