relax a memory order in once_box · qinheping/verify-rust-std@e35d9fe (original) (raw)

`@@ -8,7 +8,7 @@

`

8

8

`use crate::mem::replace;

`

9

9

`use crate::ptr::null_mut;

`

10

10

`use crate::sync::atomic::AtomicPtr;

`

11

``

`-

use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed};

`

``

11

`+

use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};

`

12

12

``

13

13

`pub(crate) struct OnceBox {

`

14

14

`ptr: AtomicPtr,

`

`@@ -60,7 +60,7 @@ impl OnceBox {

`

60

60

`#[cold]

`

61

61

`fn initialize(&self, f: impl FnOnce() -> Box) -> &T {

`

62

62

`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) {

`

64

64

`Ok(_) => unsafe { &*new_ptr },

`

65

65

`Err(ptr) => {

`

66

66

`// Lost the race to another thread.

`