Skip to content

Commit

Permalink
Debug assert lock_count in ReentrantMutex
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jun 6, 2019
1 parent e616a27 commit 4aa23e5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lock_api/src/remutex.rs
Expand Up @@ -64,6 +64,7 @@ impl<R: RawMutex, G: GetThreadId> RawReentrantMutex<R, G> {
return false;
}
self.owner.store(id, Ordering::Relaxed);
debug_assert_eq!(self.lock_count.get(), 0);
self.lock_count.set(1);
}
true
Expand All @@ -88,9 +89,8 @@ impl<R: RawMutex, G: GetThreadId> RawReentrantMutex<R, G> {
if lock_count == 0 {
self.owner.store(0, Ordering::Relaxed);
self.mutex.unlock();
} else {
self.lock_count.set(lock_count);
}
self.lock_count.set(lock_count);
}
}

Expand All @@ -101,9 +101,8 @@ impl<R: RawMutexFair, G: GetThreadId> RawReentrantMutex<R, G> {
if lock_count == 0 {
self.owner.store(0, Ordering::Relaxed);
self.mutex.unlock_fair();
} else {
self.lock_count.set(lock_count);
}
self.lock_count.set(lock_count);
}

#[inline]
Expand Down

0 comments on commit 4aa23e5

Please sign in to comment.