Skip to content

Commit

Permalink
Merge pull request #874 from misssonder/main
Browse files Browse the repository at this point in the history
Fix #867
  • Loading branch information
schungx authored May 15, 2024
2 parents d70af60 + 2ea3e0c commit 521bedc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
30 changes: 2 additions & 28 deletions src/func/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,20 +534,7 @@ pub fn locked_read<T>(value: &Locked<T>) -> Option<LockGuard<T>> {

#[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();

Check failure on line 537 in src/func/native.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,serde,metadata,internals,debugging, stable,...

mismatched types
}

/// _(internals)_ Lock a [`Locked`] resource for mutable access.
Expand All @@ -565,20 +552,7 @@ pub fn locked_write<T>(value: &Locked<T>) -> Option<LockGuardMut<T>> {

#[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();

Check failure on line 555 in src/func/native.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,serde,metadata,internals,debugging, stable,...

mismatched types
}

/// General Rust function trail object.
Expand Down
2 changes: 1 addition & 1 deletion src/types/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Check failure on line 1704 in src/types/dynamic.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,serde,metadata,internals,debugging, stable,...

no method named `flatten` found for enum `Result<dynamic::Dynamic, PoisonError<dynamic::Dynamic>>` in the current scope
// If there are outstanding references, return a cloned copy
Err(cell) => {
if let Some(guard) = crate::func::locked_read(&cell) {
Expand Down

0 comments on commit 521bedc

Please sign in to comment.