Add debug asserts to futex ReentrantMutex impl.

This commit is contained in:
Mara Bos 2022-04-06 22:15:43 +02:00
parent 43651aa34f
commit 83e8b9e4dd

View File

@ -215,6 +215,7 @@ impl ReentrantMutex {
true true
} else if self.mutex.try_lock() { } else if self.mutex.try_lock() {
self.owner.store(this_thread, Relaxed); self.owner.store(this_thread, Relaxed);
debug_assert_eq!(*self.lock_count.get(), 0);
*self.lock_count.get() = 1; *self.lock_count.get() = 1;
true true
} else { } else {
@ -229,6 +230,7 @@ impl ReentrantMutex {
} else { } else {
self.mutex.lock(); self.mutex.lock();
self.owner.store(this_thread, Relaxed); self.owner.store(this_thread, Relaxed);
debug_assert_eq!(*self.lock_count.get(), 0);
*self.lock_count.get() = 1; *self.lock_count.get() = 1;
} }
} }