Skip to content

Commit

Permalink
Remove parking_lot dependency to fix wasm32-unknown-unknown
Browse files Browse the repository at this point in the history
Works around Amanieu/parking_lot#269 where later versions of `parking_lot` were pulling in an undefined `env::now` symbol failing to be used in `wasm32-unknown-unknown` target (when not targetting web environments).

Replaced for now with just `std::sync::Mutex`, though we could optionally use `parking_lot` on non-wasm32 and use just "unsafe" single-threaded access for wasm32-unknown-unknown.

Do want that core issue in parking_lot to be resolved, or at least clarified if non-web wasm32 is a target or not. But at least this solves our problems for now in our own crate.
  • Loading branch information
repi committed Mar 6, 2021
1 parent 447025e commit 158a3e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion puffin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ doctest = false
[dependencies]
byteorder = { version = "1" }
once_cell = "1"
parking_lot = "0.11"

[dev-dependencies]
criterion = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions puffin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod merge;
pub use data::*;
pub use merge::*;

use parking_lot::Mutex;
use std::sync::Mutex;
use std::collections::BTreeMap;
use std::sync::atomic::{AtomicBool, Ordering};

Expand Down Expand Up @@ -293,10 +293,10 @@ pub struct GlobalProfiler {

impl GlobalProfiler {
/// Access to the global profiler singleton.
pub fn lock() -> parking_lot::MutexGuard<'static, Self> {
pub fn lock() -> std::sync::MutexGuard<'static, Self> {
use once_cell::sync::Lazy;
static GLOBAL_PROFILER: Lazy<Mutex<GlobalProfiler>> = Lazy::new(Default::default);
GLOBAL_PROFILER.lock()
GLOBAL_PROFILER.lock().unwrap() // panic on mutex poisioning
}

/// You need to call once every frame.
Expand Down

0 comments on commit 158a3e7

Please sign in to comment.