Migrate standard library away from compare_and_swap

This commit is contained in:
Linus Färnstrand 2020-11-20 22:27:50 +01:00
parent 4252e48256
commit 828d4ace4d
15 changed files with 79 additions and 36 deletions

View file

@ -123,9 +123,9 @@ impl Mutex {
let inner = box Inner { remutex: ReentrantMutex::uninitialized(), held: Cell::new(false) };
inner.remutex.init();
let inner = Box::into_raw(inner);
match self.lock.compare_and_swap(0, inner as usize, Ordering::SeqCst) {
0 => inner,
n => {
match self.lock.compare_exchange(0, inner as usize, Ordering::SeqCst, Ordering::SeqCst) {
Ok(_) => inner,
Err(n) => {
Box::from_raw(inner).remutex.destroy();
n as *const _
}