diff --git a/CHANGELOG.md b/CHANGELOG.md index 3249508e1d..0c494f42f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# 0.10 +# 0.10.1 + +* replaced Mutex with DebugMutex and thus with parking_lot + +# 0.10.0 * removed Js*Adapter/Facade traits * renamed JSValueRef to QuickjsValueAdapter diff --git a/Cargo.toml b/Cargo.toml index 55aedbd4bb..b6bdd98bef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quickjs_runtime" -version = "0.10.0" +version = "0.10.1" authors = ["Andries Hiemstra "] edition = "2018" description = "Wrapper API and utils for the QuickJS JavaScript engine with support for Promise, Modules, Async/await" diff --git a/src/jsutils/promises.rs b/src/jsutils/promises.rs index 88fa6399dd..88aab91e5e 100644 --- a/src/jsutils/promises.rs +++ b/src/jsutils/promises.rs @@ -62,7 +62,7 @@ where err.get_message(), err.get_stack(), ) - .expect("could not create str"); + .expect("could not create error"); prom_ref .js_promise_reject(realm, &err_ref) .expect("prom rejection failed"); @@ -77,7 +77,7 @@ where err.get_message(), err.get_stack(), ) - .expect("could not create str"); + .expect("could not create error"); prom_ref .js_promise_reject(realm, &err_ref) .expect("prom rejection failed"); diff --git a/src/quickjsrealmadapter.rs b/src/quickjsrealmadapter.rs index a111fb627b..3d461e35d3 100644 --- a/src/quickjsrealmadapter.rs +++ b/src/quickjsrealmadapter.rs @@ -1015,7 +1015,7 @@ impl QuickJsRealmAdapter { Ok(obj) } JsValueFacade::Promise { producer } => { - let producer = &mut *producer.lock().unwrap(); + let producer = &mut *producer.lock("from_js_value_facade").unwrap(); if producer.is_some() { self.create_resolving_promise_async(producer.take().unwrap(), |realm, jsvf| { realm.from_js_value_facade(jsvf) diff --git a/src/values.rs b/src/values.rs index 3f2e148e62..4ac47f11e8 100644 --- a/src/values.rs +++ b/src/values.rs @@ -5,6 +5,7 @@ use crate::quickjsvalueadapter::QuickJsValueAdapter; use crate::reflection::JsProxyInstanceId; use futures::executor::block_on; use futures::Future; +use hirofa_utils::debug_mutex::DebugMutex; use hirofa_utils::resolvable_future::ResolvableFuture; use serde::Serialize; use serde_json::Value; @@ -12,14 +13,14 @@ use std::collections::HashMap; use std::error::Error; use std::fmt::{Debug, Formatter}; use std::pin::Pin; -use std::sync::{Arc, Mutex, Weak}; +use std::sync::{Arc, Weak}; use string_cache::DefaultAtom; pub struct CachedJsObjectRef { pub(crate) id: i32, rti: Weak, realm_id: String, - drop_action: Mutex>>, + drop_action: DebugMutex>>, } pub struct CachedJsPromiseRef { @@ -67,7 +68,10 @@ impl CachedJsObjectRef { id, rti, realm_id: realm_name, - drop_action: Mutex::new(Some(Box::new(drop_action))), + drop_action: DebugMutex::new( + Some(Box::new(drop_action)), + "CachedJsObjectRef.drop_action", + ), } } pub async fn to_json_string(&self) -> Result { @@ -184,7 +188,7 @@ impl CachedJsObjectRef { impl Drop for CachedJsObjectRef { fn drop(&mut self) { - let lck = &mut *self.drop_action.lock().unwrap(); + let lck = &mut *self.drop_action.lock("drop").unwrap(); if let Some(da) = lck.take() { da(); } @@ -376,7 +380,7 @@ pub enum JsValueFacade { }, // promise created from rust which will run an async producer Promise { - producer: Mutex< + producer: DebugMutex< Option> + Send + 'static>>>, >, }, @@ -466,7 +470,7 @@ impl JsValueFacade { P: Future> + Send + 'static, { JsValueFacade::Promise { - producer: Mutex::new(Some(Box::pin(producer))), + producer: DebugMutex::new(Some(Box::pin(producer)), "JsValueFacade::Promise.producer"), } }