diff --git a/Cargo.toml b/Cargo.toml index 642382a13..28afb6a0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ bitflags = { version = "2.0.0", default-features = false } smartstring = { version = "1.0.0", default-features = false } rhai_codegen = { version = "2.1.0", path = "codegen" } -no-std-compat = { git = "https://gitlab.com/jD91mZM2/no-std-compat", version = "0.4.1", default-features = false, features = ["alloc"], optional = true } +no-std-compat = { git = "https://gitlab.com/jD91mZM2/no-std-compat", version = "0.4.1", default-features = false, features = ["alloc", "compat_sync"], optional = true } libm = { version = "0.2.0", default-features = false, optional = true } hashbrown = { version = "0.14.0", optional = true } core-error = { version = "0.0.0", default-features = false, features = ["alloc"], optional = true } diff --git a/src/func/native.rs b/src/func/native.rs index 94f128067..446f71d26 100644 --- a/src/func/native.rs +++ b/src/func/native.rs @@ -534,20 +534,7 @@ pub fn locked_read(value: &Locked) -> Option> { #[cfg(feature = "sync")] #[cfg(not(feature = "unchecked"))] - { - // Spin-lock for a short while before giving up - for _ in 0..10 { - match value.try_read() { - Ok(guard) => return Some(guard), - Err(std::sync::TryLockError::WouldBlock) => { - std::thread::sleep(std::time::Duration::from_secs(1)) - } - Err(_) => return None, - } - } - - return None; - } + return value.try_read(); } /// _(internals)_ Lock a [`Locked`] resource for mutable access. @@ -565,20 +552,7 @@ pub fn locked_write(value: &Locked) -> Option> { #[cfg(feature = "sync")] #[cfg(not(feature = "unchecked"))] - { - // Spin-lock for a short while before giving up - for _ in 0..10 { - match value.try_write() { - Ok(guard) => return Some(guard), - Err(std::sync::TryLockError::WouldBlock) => { - std::thread::sleep(std::time::Duration::from_secs(1)) - } - Err(_) => return None, - } - } - - return None; - } + return value.try_write(); } /// General Rust function trail object. diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index 52097a380..b54410adb 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -1701,7 +1701,7 @@ impl Dynamic { #[cfg(not(feature = "sync"))] Ok(value) => value.into_inner().flatten(), #[cfg(feature = "sync")] - Ok(value) => value.into_inner().unwrap().flatten(), + Ok(value) => value.into_inner().flatten(), // If there are outstanding references, return a cloned copy Err(cell) => { if let Some(guard) = crate::func::locked_read(&cell) {