Skip to content

Commit d09ac4c

Browse files
authored
Merge pull request spacejam#1420 from spacejam/tyler_fix_arm_cas
Fix arm compare_exchange_weak behavior
2 parents 987218d + 60b4375 commit d09ac4c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/fastlock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
ops::{Deref, DerefMut},
44
sync::atomic::{
55
AtomicBool,
6-
Ordering::{Acquire, Release},
6+
Ordering::{AcqRel, Acquire, Release},
77
},
88
};
99

@@ -56,7 +56,7 @@ impl<T> FastLock<T> {
5656

5757
pub fn try_lock(&self) -> Option<FastLockGuard<'_, T>> {
5858
let lock_result =
59-
self.lock.compare_exchange_weak(false, true, Acquire, Acquire);
59+
self.lock.compare_exchange_weak(false, true, AcqRel, Acquire);
6060

6161
let success = lock_result.is_ok();
6262

src/lru.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ impl AccessQueue {
9797
// install new writer
9898
let new = Box::into_raw(Box::new(AccessBlock::new(item)));
9999
debug_delay();
100-
let res = self.writing.compare_exchange_weak(
100+
let res = self.writing.compare_exchange(
101101
head,
102102
new,
103-
Ordering::Release,
104-
Ordering::Relaxed,
103+
Ordering::AcqRel,
104+
Ordering::Acquire,
105105
);
106106
if res.is_err() {
107107
// we lost the CAS, free the new item that was
@@ -120,11 +120,11 @@ impl AccessQueue {
120120
// we loop because maybe other threads are pushing stuff too
121121
block.next.store(full_list_ptr, Ordering::Release);
122122
debug_delay();
123-
ret = self.full_list.compare_exchange_weak(
123+
ret = self.full_list.compare_exchange(
124124
full_list_ptr,
125125
head,
126-
Ordering::Release,
127-
Ordering::Relaxed,
126+
Ordering::AcqRel,
127+
Ordering::Acquire,
128128
);
129129
ret.is_err()
130130
} {

0 commit comments

Comments
 (0)