From 15213aca407f541dba75ff50b4eb0ea5576be86b Mon Sep 17 00:00:00 2001 From: Alisdair Owens Date: Mon, 2 May 2016 20:12:07 +0100 Subject: [PATCH] Alter once to use acquire semantics for fast path --- src/libstd/sync/once.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index e228d236a3ca7..dad5682b98b8f 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -201,7 +201,7 @@ impl Once { #[stable(feature = "rust1", since = "1.0.0")] pub fn call_once(&'static self, f: F) where F: FnOnce() { // Fast path, just see if we've completed initialization. - if self.state.load(Ordering::SeqCst) == COMPLETE { + if self.state.load(Ordering::Acquire) == COMPLETE { return } @@ -222,7 +222,7 @@ impl Once { #[unstable(feature = "once_poison", issue = "31688")] pub fn call_once_force(&'static self, f: F) where F: FnOnce(&OnceState) { // same as above, just with a different parameter to `call_inner`. - if self.state.load(Ordering::SeqCst) == COMPLETE { + if self.state.load(Ordering::Acquire) == COMPLETE { return }