@@ -392,7 +392,10 @@ impl Event {
392
392
let new = Arc :: into_raw ( new) as * mut Inner ;
393
393
394
394
// 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) ;
396
399
397
400
// Check if the old pointer value was indeed null.
398
401
if inner. is_null ( ) {
@@ -970,7 +973,7 @@ fn full_fence() {
970
973
// a `SeqCst` fence.
971
974
//
972
975
// 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.
974
977
//
975
978
// Both instructions have the effect of a full barrier, but empirical benchmarks have shown
976
979
// that the second one is sometimes a bit faster.
@@ -979,7 +982,7 @@ fn full_fence() {
979
982
// temporary atomic variable and compare-and-exchanging its value. No sane compiler to
980
983
// x86 platforms is going to optimize this away.
981
984
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 ) ;
983
986
} else {
984
987
atomic:: fence ( Ordering :: SeqCst ) ;
985
988
}
0 commit comments