diff --git a/core/fast_lock.rs b/core/fast_lock.rs index 9d2c1dc2b..8b3483bc3 100644 --- a/core/fast_lock.rs +++ b/core/fast_lock.rs @@ -37,14 +37,21 @@ impl FastLock { } pub fn lock(&self) -> FastLockGuard { - while self.lock.compare_and_swap(false, true, Ordering::Acquire) { + while self + .lock + .compare_exchange(false, true, Ordering::Acquire, Ordering::Acquire) + .is_err() + { std::thread::yield_now(); } FastLockGuard { lock: self } } pub fn unlock(&self) { - assert!(self.lock.compare_and_swap(true, false, Ordering::Acquire)); + assert!(self + .lock + .compare_exchange(true, false, Ordering::Acquire, Ordering::Acquire) + .is_ok()); } pub fn get_mut(&self) -> &mut T {