We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
once_box
1 parent f79fae3 commit 937d13bCopy full SHA for 937d13b
library/std/src/sys/sync/once_box.rs
@@ -8,7 +8,7 @@
8
use crate::mem::replace;
9
use crate::ptr::null_mut;
10
use crate::sync::atomic::AtomicPtr;
11
-use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed};
+use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
12
13
pub(crate) struct OnceBox<T> {
14
ptr: AtomicPtr<T>,
@@ -60,7 +60,7 @@ impl<T> OnceBox<T> {
60
#[cold]
61
fn initialize(&self, f: impl FnOnce() -> Box<T>) -> &T {
62
let new_ptr = Box::into_raw(f());
63
- match self.ptr.compare_exchange(null_mut(), new_ptr, AcqRel, Acquire) {
+ match self.ptr.compare_exchange(null_mut(), new_ptr, Release, Acquire) {
64
Ok(_) => unsafe { &*new_ptr },
65
Err(ptr) => {
66
// Lost the race to another thread.
0 commit comments