Use parking_lot::const_recursive_mutex instead of lazy_static

This commit is contained in:
Thom Chiovoloni 2020-12-02 23:54:38 -08:00
parent 54ab45b15c
commit c768fc49a4
5 changed files with 4 additions and 12 deletions

View File

@ -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]

View File

@ -615,7 +615,6 @@ dependencies = [
"bitflags",
"glium",
"imgui-sys",
"lazy_static",
"parking_lot",
]

View File

@ -59,11 +59,9 @@ pub struct Context {
clipboard_ctx: Option<Box<ClipboardContext>>,
}
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 {

View File

@ -1,6 +1,4 @@
pub extern crate imgui_sys as sys;
#[macro_use]
extern crate lazy_static;
use std::cell;
use std::ffi::CStr;

View File

@ -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();