diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-07-06 23:48:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 23:48:01 -0400 |
commit | 7fc0e8ec8cd4b18ba10a04cf0ac2bee48826de3d (patch) | |
tree | 70e078538ae0f3467e8a519b918ae936587ce2d4 /core | |
parent | 78ac19f51f48984ea16f97a0c574fa507544b8d5 (diff) |
chore: use parking_lot for synchronization primitives to align with tokio (#11289)
parking_lot is already transitively used in tokio via the "full" cargo feature
Diffstat (limited to 'core')
-rw-r--r-- | core/Cargo.toml | 1 | ||||
-rw-r--r-- | core/inspector.rs | 4 | ||||
-rw-r--r-- | core/lib.rs | 1 | ||||
-rw-r--r-- | core/modules.rs | 14 |
4 files changed, 11 insertions, 9 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml index 8a5420af3..a5a170cc8 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,6 +19,7 @@ indexmap = "1.6.2" lazy_static = "1.4.0" libc = "0.2.93" log = "0.4.14" +parking_lot = "0.11.1" pin-project = "1.0.6" rusty_v8 = "0.25.0" serde = { version = "1.0.125", features = ["derive"] } diff --git a/core/inspector.rs b/core/inspector.rs index f6e348d88..d8a51e601 100644 --- a/core/inspector.rs +++ b/core/inspector.rs @@ -23,6 +23,7 @@ use crate::serde_json; use crate::serde_json::json; use crate::serde_json::Value; use crate::v8; +use parking_lot::Mutex; use std::cell::BorrowMutError; use std::cell::RefCell; use std::collections::HashMap; @@ -35,7 +36,6 @@ use std::ptr; use std::ptr::NonNull; use std::rc::Rc; use std::sync::Arc; -use std::sync::Mutex; use std::thread; /// If first argument is `None` then it's a notification, otherwise @@ -452,7 +452,7 @@ impl InspectorWaker { where F: FnOnce(&mut InspectorWakerInner) -> R, { - let mut g = self.0.lock().unwrap(); + let mut g = self.0.lock(); update_fn(&mut g) } } diff --git a/core/lib.rs b/core/lib.rs index 8c8861c79..a9f6d5d8b 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -18,6 +18,7 @@ mod runtime; // Re-exports pub use futures; +pub use parking_lot; pub use rusty_v8 as v8; pub use serde; pub use serde_json; diff --git a/core/modules.rs b/core/modules.rs index 443120363..765536107 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -719,6 +719,7 @@ mod tests { use crate::OpPayload; use crate::RuntimeOptions; use futures::future::FutureExt; + use parking_lot::Mutex; use std::error::Error; use std::fmt; use std::future::Future; @@ -726,7 +727,6 @@ mod tests { use std::path::PathBuf; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; - use std::sync::Mutex; // TODO(ry) Sadly FuturesUnordered requires the current task to be set. So // even though we are only using poll() in these tests and not Tokio, we must @@ -856,7 +856,7 @@ mod tests { _maybe_referrer: Option<ModuleSpecifier>, _is_dyn_import: bool, ) -> Pin<Box<ModuleSourceFuture>> { - let mut loads = self.loads.lock().unwrap(); + let mut loads = self.loads.lock(); loads.push(module_specifier.to_string()); let url = module_specifier.to_string(); DelayedSourceCodeFuture { url, counter: 0 }.boxed() @@ -908,7 +908,7 @@ mod tests { runtime.mod_evaluate(a_id); futures::executor::block_on(runtime.run_event_loop(false)).unwrap(); - let l = loads.lock().unwrap(); + let l = loads.lock(); assert_eq!( l.to_vec(), vec![ @@ -1369,7 +1369,7 @@ mod tests { runtime.mod_evaluate(circular1_id); runtime.run_event_loop(false).await.unwrap(); - let l = loads.lock().unwrap(); + let l = loads.lock(); assert_eq!( l.to_vec(), vec![ @@ -1441,7 +1441,7 @@ mod tests { let redirect1_id = result.unwrap(); runtime.mod_evaluate(redirect1_id); runtime.run_event_loop(false).await.unwrap(); - let l = loads.lock().unwrap(); + let l = loads.lock(); assert_eq!( l.to_vec(), vec![ @@ -1517,7 +1517,7 @@ mod tests { for _ in 0..10 { let result = recursive_load.poll_unpin(&mut cx); assert!(result.is_pending()); - let l = loads.lock().unwrap(); + let l = loads.lock(); assert_eq!( l.to_vec(), vec![ @@ -1591,7 +1591,7 @@ mod tests { runtime.mod_evaluate(main_id); futures::executor::block_on(runtime.run_event_loop(false)).unwrap(); - let l = loads.lock().unwrap(); + let l = loads.lock(); assert_eq!( l.to_vec(), vec!["file:///b.js", "file:///c.js", "file:///d.js"] |