From e43aef0ef9cc9d2d12c138b36fd817f7c41d0152 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 19 Mar 2024 15:03:29 +0100 Subject: [PATCH] SeqCst->{Release,Acquire} in sys_common::thread_local_key. SeqCst is unnecessary here. --- library/std/src/sys_common/thread_local_key.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys_common/thread_local_key.rs b/library/std/src/sys_common/thread_local_key.rs index 204834984a2..7dcc1141099 100644 --- a/library/std/src/sys_common/thread_local_key.rs +++ b/library/std/src/sys_common/thread_local_key.rs @@ -128,7 +128,7 @@ pub unsafe fn set(&self, val: *mut u8) { #[inline] unsafe fn key(&self) -> imp::Key { - match self.key.load(Ordering::Relaxed) { + match self.key.load(Ordering::Acquire) { KEY_SENTVAL => self.lazy_init() as imp::Key, n => n as imp::Key, } @@ -156,8 +156,8 @@ unsafe fn lazy_init(&self) -> usize { match self.key.compare_exchange( KEY_SENTVAL, key as usize, - Ordering::SeqCst, - Ordering::SeqCst, + Ordering::Release, + Ordering::Acquire, ) { // The CAS succeeded, so we've created the actual key Ok(_) => key as usize,