diff --git a/codegen/src/worktable/generator/queries/delete.rs b/codegen/src/worktable/generator/queries/delete.rs index 89bf166..2a25750 100644 --- a/codegen/src/worktable/generator/queries/delete.rs +++ b/codegen/src/worktable/generator/queries/delete.rs @@ -48,7 +48,7 @@ impl Generator { #delete_logic lock.unlock(); // Releases locks - self.0.lock_map.remove_with_lock_check(&pk).await; // Removes locks + self.0.lock_map.remove_with_lock_check(&pk); // Removes locks core::result::Result::Ok(()) } diff --git a/codegen/src/worktable/generator/queries/in_place.rs b/codegen/src/worktable/generator/queries/in_place.rs index 922eb37..c8c65f6 100644 --- a/codegen/src/worktable/generator/queries/in_place.rs +++ b/codegen/src/worktable/generator/queries/in_place.rs @@ -126,7 +126,7 @@ impl Generator { }; lock.unlock(); - self.0.lock_map.remove_with_lock_check(&pk).await; + self.0.lock_map.remove_with_lock_check(&pk); Ok(()) } diff --git a/codegen/src/worktable/generator/queries/update.rs b/codegen/src/worktable/generator/queries/update.rs index 6a9512b..c2f3c0c 100644 --- a/codegen/src/worktable/generator/queries/update.rs +++ b/codegen/src/worktable/generator/queries/update.rs @@ -78,7 +78,7 @@ impl Generator { self.0.update_state.remove(&pk); lock.unlock(); - self.0.lock_map.remove_with_lock_check(&pk).await; // Removes locks + self.0.lock_map.remove_with_lock_check(&pk); // Removes locks return core::result::Result::Ok(()); } @@ -119,7 +119,7 @@ impl Generator { self.0.update_state.remove(&pk); lock.unlock(); // Releases locks - self.0.lock_map.remove_with_lock_check(&pk).await; // Removes locks + self.0.lock_map.remove_with_lock_check(&pk); // Removes locks #persist_call @@ -273,7 +273,7 @@ impl Generator { } lock.unlock(); // Releases locks - self.0.lock_map.remove_with_lock_check(&pk).await; // Removes locks + self.0.lock_map.remove_with_lock_check(&pk); // Removes locks return core::result::Result::Ok(()); } @@ -490,7 +490,7 @@ impl Generator { #diff_process_remove lock.unlock(); - self.0.lock_map.remove_with_lock_check(&pk).await; + self.0.lock_map.remove_with_lock_check(&pk); #persist_call @@ -566,7 +566,7 @@ impl Generator { } lock.unlock(); // Releases locks - self.0.lock_map.remove_with_lock_check(&pk).await; // Removes locks + self.0.lock_map.remove_with_lock_check(&pk); // Removes locks continue; } else { @@ -633,7 +633,7 @@ impl Generator { } for (pk, lock) in pk_to_unlock { lock.unlock(); - self.0.lock_map.remove_with_lock_check(&pk).await; + self.0.lock_map.remove_with_lock_check(&pk); } core::result::Result::Ok(()) } @@ -721,7 +721,7 @@ impl Generator { #diff_process_remove lock.unlock(); - self.0.lock_map.remove_with_lock_check(&pk).await; + self.0.lock_map.remove_with_lock_check(&pk); #persist_call diff --git a/src/lock/map.rs b/src/lock/map.rs index c8f88fa..57a9dce 100644 --- a/src/lock/map.rs +++ b/src/lock/map.rs @@ -44,13 +44,14 @@ where } #[allow(clippy::await_holding_lock)] - pub async fn remove_with_lock_check(&self, key: &PrimaryKey) + pub fn remove_with_lock_check(&self, key: &PrimaryKey) where LockType: RowLock, { let mut set = self.map.write(); if let Some(lock) = set.get(key).cloned() - && let Ok(guard) = lock.try_read() + && let Ok(guard) = lock.try_write() + && Arc::strong_count(&lock) == 1 && !guard.is_locked() { set.remove(key);