Skip to content

Commit e35d9fe

Browse files
committed
relax a memory order in once_box
1 parent 7d1457e commit e35d9fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

std/src/sys/sync/once_box.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use crate::mem::replace;
99
use crate::ptr::null_mut;
1010
use crate::sync::atomic::AtomicPtr;
11-
use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed};
11+
use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
1212

1313
pub(crate) struct OnceBox<T> {
1414
ptr: AtomicPtr<T>,
@@ -60,7 +60,7 @@ impl<T> OnceBox<T> {
6060
#[cold]
6161
fn initialize(&self, f: impl FnOnce() -> Box<T>) -> &T {
6262
let new_ptr = Box::into_raw(f());
63-
match self.ptr.compare_exchange(null_mut(), new_ptr, AcqRel, Acquire) {
63+
match self.ptr.compare_exchange(null_mut(), new_ptr, Release, Acquire) {
6464
Ok(_) => unsafe { &*new_ptr },
6565
Err(ptr) => {
6666
// Lost the race to another thread.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy