Skip to content

Commit

Permalink
relax a memory order in once_box
Browse files Browse the repository at this point in the history
  • Loading branch information
slanterns committed Oct 15, 2024
1 parent f79fae3 commit bbe5dde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/std/src/sys/sync/once_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<T> OnceBox<T> {
#[cold]
fn initialize(&self, f: impl FnOnce() -> Box<T>) -> &T {
let new_ptr = Box::into_raw(f());
match self.ptr.compare_exchange(null_mut(), new_ptr, AcqRel, Acquire) {
match self.ptr.compare_exchange(null_mut(), new_ptr, Release, Acquire) {
Ok(_) => unsafe { &*new_ptr },
Err(ptr) => {
// Lost the race to another thread.
Expand Down

0 comments on commit bbe5dde

Please sign in to comment.