From 3737067994c8c79783a6555dd388b02b72738a79 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 17 May 2020 16:42:46 +0200 Subject: [PATCH] mutexes: crash rather than deadlock --- emigui/src/context.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/emigui/src/context.rs b/emigui/src/context.rs index c902da8c..3f929440 100644 --- a/emigui/src/context.rs +++ b/emigui/src/context.rs @@ -87,15 +87,15 @@ impl Context { } pub fn memory(&self) -> parking_lot::MutexGuard<'_, Memory> { - self.memory.lock() + self.memory.try_lock().expect("memory already locked") } pub fn graphics(&self) -> parking_lot::MutexGuard<'_, GraphicLayers> { - self.graphics.lock() + self.graphics.try_lock().expect("graphics already locked") } pub fn output(&self) -> parking_lot::MutexGuard<'_, Output> { - self.output.lock() + self.output.try_lock().expect("output already locked") } /// Input previous frame. Compare to `input()` to check for changes. @@ -127,11 +127,11 @@ impl Context { // TODO: return MutexGuard pub fn style(&self) -> Style { - *self.style.lock() + *self.style.try_lock().expect("style already locked") } pub fn set_style(&self, style: Style) { - *self.style.lock() = style; + *self.style.try_lock().expect("style already locked") = style; } pub fn pixels_per_point(&self) -> f32 {