diff --git a/Cargo.lock b/Cargo.lock index 00bc07bb..5b531223 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3178,7 +3178,6 @@ dependencies = [ "dashmap 6.0.1", "derive_more", "indexmap", - "parking_lot", "pprof", "rand", "rand_xorshift", diff --git a/crates/libmdbx-rs/Cargo.toml b/crates/libmdbx-rs/Cargo.toml index e02d1bc8..df68e76b 100644 --- a/crates/libmdbx-rs/Cargo.toml +++ b/crates/libmdbx-rs/Cargo.toml @@ -12,7 +12,6 @@ bitflags = "2" byteorder = "1" derive_more = "0.99" indexmap = "2" -parking_lot = "0.12" thiserror = "1" dashmap = { version = "6.0.1", features = ["inline"], optional = true } tracing = "0.1.0" diff --git a/crates/libmdbx-rs/src/codec.rs b/crates/libmdbx-rs/src/codec.rs index 15f20204..b4964b12 100644 --- a/crates/libmdbx-rs/src/codec.rs +++ b/crates/libmdbx-rs/src/codec.rs @@ -41,10 +41,14 @@ impl<'tx> TableObject for Cow<'tx, [u8]> { #[cfg(not(feature = "return-borrowed"))] { - let is_dirty = (!K::IS_READ_ONLY) && - crate::error::mdbx_result(ffi::mdbx_is_dirty(_txn, data_val.iov_base))?; + let is_dirty = (!K::IS_READ_ONLY) + && crate::error::mdbx_result(ffi::mdbx_is_dirty(_txn, data_val.iov_base))?; - Ok(if is_dirty { Cow::Owned(s.to_vec()) } else { Cow::Borrowed(s) }) + Ok(if is_dirty { + Cow::Owned(s.to_vec()) + } else { + Cow::Borrowed(s) + }) } } } @@ -81,7 +85,7 @@ impl TableObject for ObjectLength { impl TableObject for [u8; LEN] { fn decode(data_val: &[u8]) -> Result { if data_val.len() != LEN { - return Err(Error::DecodeErrorLenDiff) + return Err(Error::DecodeErrorLenDiff); } let mut a = [0; LEN]; a[..].copy_from_slice(data_val); diff --git a/crates/libmdbx-rs/src/transaction.rs b/crates/libmdbx-rs/src/transaction.rs index ea12bf70..43aef821 100644 --- a/crates/libmdbx-rs/src/transaction.rs +++ b/crates/libmdbx-rs/src/transaction.rs @@ -8,13 +8,12 @@ use crate::{ }; use ffi::{MDBX_txn_flags_t, MDBX_TXN_RDONLY, MDBX_TXN_READWRITE}; use indexmap::IndexSet; -use parking_lot::{Mutex, MutexGuard}; use std::{ ffi::{c_uint, c_void}, fmt::{self, Debug}, mem::size_of, ptr, slice, - sync::{atomic::AtomicBool, mpsc::sync_channel, Arc}, + sync::{atomic::AtomicBool, mpsc::sync_channel, Arc, Mutex, MutexGuard}, time::Duration, }; @@ -173,7 +172,7 @@ where } pub fn prime_for_permaopen(&self, db: Database) { - self.inner.primed_dbis.lock().insert(db.dbi()); + self.inner.primed_dbis.lock().unwrap().insert(db.dbi()); } /// Commits the transaction and returns table handles permanently open until dropped. @@ -211,6 +210,7 @@ where self.inner .primed_dbis .lock() + .unwrap() .iter() .map(|&dbi| Database::new_from_ptr(dbi, self.env().clone())) .collect(), @@ -607,7 +607,7 @@ impl TransactionPtr { } fn lock(&self) -> MutexGuard<'_, ()> { - if let Some(lock) = self.lock.try_lock() { + if let Ok(lock) = self.lock.try_lock() { lock } else { tracing::debug!( @@ -616,7 +616,7 @@ impl TransactionPtr { backtrace = %std::backtrace::Backtrace::force_capture(), "Transaction lock is already acquired, blocking..." ); - self.lock.lock() + self.lock.lock().unwrap() } }