@@ -392,7 +392,10 @@ impl Event {
392392 let new = Arc :: into_raw ( new) as * mut Inner ;
393393
394394 // Attempt to replace the null-pointer with the new state pointer.
395- inner = self . inner . compare_and_swap ( inner, new, Ordering :: AcqRel ) ;
395+ inner = self
396+ . inner
397+ . compare_exchange ( inner, new, Ordering :: AcqRel , Ordering :: Acquire )
398+ . unwrap_or_else ( |x| x) ;
396399
397400 // Check if the old pointer value was indeed null.
398401 if inner. is_null ( ) {
@@ -970,7 +973,7 @@ fn full_fence() {
970973 // a `SeqCst` fence.
971974 //
972975 // 1. `atomic::fence(SeqCst)`, which compiles into a `mfence` instruction.
973- // 2. `_.compare_and_swap (_, _, SeqCst)`, which compiles into a `lock cmpxchg` instruction.
976+ // 2. `_.compare_exchange (_, _, SeqCst , SeqCst)`, which compiles into a `lock cmpxchg` instruction.
974977 //
975978 // Both instructions have the effect of a full barrier, but empirical benchmarks have shown
976979 // that the second one is sometimes a bit faster.
@@ -979,7 +982,7 @@ fn full_fence() {
979982 // temporary atomic variable and compare-and-exchanging its value. No sane compiler to
980983 // x86 platforms is going to optimize this away.
981984 let a = AtomicUsize :: new ( 0 ) ;
982- a . compare_and_swap ( 0 , 1 , Ordering :: SeqCst ) ;
985+ let _ = a . compare_exchange ( 0 , 1 , Ordering :: SeqCst , Ordering :: SeqCst ) ;
983986 } else {
984987 atomic:: fence ( Ordering :: SeqCst ) ;
985988 }
0 commit comments