From c768fc49a48f0788110397e453cb7c809efbe9f5 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Wed, 2 Dec 2020 23:54:38 -0800 Subject: [PATCH] Use parking_lot::const_recursive_mutex instead of lazy_static --- Cargo.toml | 1 - imgui-examples/Cargo.lock | 1 - src/context.rs | 8 +++----- src/lib.rs | 2 -- src/test.rs | 4 +--- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f7dc9d9..043c34c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ bitflags = "1.0" glium = { version = "0.28", default-features = false, optional = true } gfx = { version = "0.18", optional = true } imgui-sys = { version = "0.6.0", path = "imgui-sys" } -lazy_static = "1.1" parking_lot = "0.11" [features] diff --git a/imgui-examples/Cargo.lock b/imgui-examples/Cargo.lock index f37a861..aa7a5c9 100644 --- a/imgui-examples/Cargo.lock +++ b/imgui-examples/Cargo.lock @@ -615,7 +615,6 @@ dependencies = [ "bitflags", "glium", "imgui-sys", - "lazy_static", "parking_lot", ] diff --git a/src/context.rs b/src/context.rs index f032ba2..66029ea 100644 --- a/src/context.rs +++ b/src/context.rs @@ -59,11 +59,9 @@ pub struct Context { clipboard_ctx: Option>, } -lazy_static! { - // This mutex needs to be used to guard all public functions that can affect the underlying - // Dear ImGui active context - static ref CTX_MUTEX: ReentrantMutex<()> = ReentrantMutex::new(()); -} +// This mutex needs to be used to guard all public functions that can affect the underlying +// Dear ImGui active context +static CTX_MUTEX: ReentrantMutex<()> = parking_lot::const_reentrant_mutex(()); fn clear_current_context() { unsafe { diff --git a/src/lib.rs b/src/lib.rs index 0c67b39..fb8216a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,4 @@ pub extern crate imgui_sys as sys; -#[macro_use] -extern crate lazy_static; use std::cell; use std::ffi::CStr; diff --git a/src/test.rs b/src/test.rs index 9b1ad35..3cc5e0c 100644 --- a/src/test.rs +++ b/src/test.rs @@ -3,9 +3,7 @@ use std::ptr; use crate::context::Context; -lazy_static! { - pub static ref TEST_MUTEX: ReentrantMutex<()> = ReentrantMutex::new(()); -} +pub static TEST_MUTEX: ReentrantMutex<()> = parking_lot::const_reentrant_mutex(()); pub fn test_ctx() -> (ReentrantMutexGuard<'static, ()>, Context) { let guard = TEST_MUTEX.lock();