Skip to content

Commit

Permalink
Merge pull request rust-lang#219 from dwrensha/seq-cst
Browse files Browse the repository at this point in the history
Use SeqCst instead of Acquire and Release in Lock.
  • Loading branch information
alexcrichton authored Nov 1, 2016
2 parents 43e290f + 703afd7 commit 1993896
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>`.
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<T> Lock<T> {
/// 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<TryLock<T>> {
if !self.locked.swap(true, Acquire) {
if !self.locked.swap(true, SeqCst) {
Some(TryLock { __ptr: self })
} else {
None
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1993896

Please sign in to comment.