Skip to content

Commit

Permalink
debug: remove parking_lot
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-rise committed Aug 15, 2024
1 parent 3c42de2 commit a25555c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/libmdbx-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 8 additions & 4 deletions crates/libmdbx-rs/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
}
Expand Down Expand Up @@ -81,7 +85,7 @@ impl TableObject for ObjectLength {
impl<const LEN: usize> TableObject for [u8; LEN] {
fn decode(data_val: &[u8]) -> Result<Self, Error> {
if data_val.len() != LEN {
return Err(Error::DecodeErrorLenDiff)
return Err(Error::DecodeErrorLenDiff);
}
let mut a = [0; LEN];
a[..].copy_from_slice(data_val);
Expand Down
10 changes: 5 additions & 5 deletions crates/libmdbx-rs/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -211,6 +210,7 @@ where
self.inner
.primed_dbis
.lock()
.unwrap()
.iter()
.map(|&dbi| Database::new_from_ptr(dbi, self.env().clone()))
.collect(),
Expand Down Expand Up @@ -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!(
Expand All @@ -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()
}
}

Expand Down

0 comments on commit a25555c

Please sign in to comment.