Panic mutexes that can't lock for 30 seconds, in debug builds (#7468)

I'm trying to debug a suspected deadlock in the CI for
https://github.com/emilk/egui/pull/7467

Since we use our own mutex wrappers, we can just panic if the lock is
too slow. Ugly and effective :)
This commit is contained in:
Emil Ernerfeldt 2025-08-21 15:31:56 +02:00 committed by GitHub
parent 7c5798289d
commit 1da1d57c11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -23,7 +23,13 @@ mod mutex_impl {
#[inline(always)]
pub fn lock(&self) -> MutexGuard<'_, T> {
self.0.lock()
if cfg!(debug_assertions) {
self.0
.try_lock_for(std::time::Duration::from_secs(30))
.expect("Looks like a deadlock!")
} else {
self.0.lock()
}
}
}
}