Update mutex.rs

This commit is contained in:
Stjepan Glavina 2020-08-10 13:58:28 +02:00 committed by GitHub
parent fe9ec7e60e
commit 842d1aa118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1,4 +1,4 @@
//! A simple mutex implementation.
tr//! A simple mutex implementation.
//!
//! This mutex exposes both blocking and async methods for acquiring a lock.
@ -40,7 +40,7 @@ impl<T> Mutex<T> {
/// Attempts to acquire a lock.
fn try_lock(&self) -> Option<MutexGuard<'_, T>> {
if self.locked.swap(true, Ordering::Acquire) {
if !self.locked.swap(true, Ordering::Acquire) {
Some(MutexGuard(self))
} else {
None