From 703afd7b0be1762cb7961a1ba67b20bd9a601c18 Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Mon, 31 Oct 2016 20:42:30 -0400 Subject: [PATCH] Use SeqCst instead of Acquire and Release in Lock. --- src/lock.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lock.rs b/src/lock.rs index 24c26c956da..0e233e19e47 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -8,7 +8,7 @@ extern crate core; use self::core::cell::UnsafeCell; use self::core::ops::{Deref, DerefMut}; -use self::core::sync::atomic::Ordering::{Acquire, Release}; +use self::core::sync::atomic::Ordering::{SeqCst}; use self::core::sync::atomic::AtomicBool; /// A "mutex" around a value, similar to `std::sync::Mutex`. @@ -54,7 +54,7 @@ impl Lock { /// If `None` is returned then the lock is already locked, either elsewhere /// on this thread or on another thread. pub fn try_lock(&self) -> Option> { - if !self.locked.swap(true, Acquire) { + if !self.locked.swap(true, SeqCst) { Some(TryLock { __ptr: self }) } else { None @@ -84,7 +84,7 @@ impl<'a, T> DerefMut for TryLock<'a, T> { impl<'a, T> Drop for TryLock<'a, T> { fn drop(&mut self) { - self.__ptr.locked.store(false, Release); + self.__ptr.locked.store(false, SeqCst); } }