Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parking_lot dependency #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ once_cell = "1.10.0"
serde = { version = "1", optional = true }
phf_shared = "0.11"
new_debug_unreachable = "1.0.2"
parking_lot = "0.12"

[[test]]
name = "small-stack"
Expand Down
6 changes: 3 additions & 3 deletions src/dynamic_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// except according to those terms.

use once_cell::sync::Lazy;
use parking_lot::Mutex;
use std::borrow::Cow;
use std::mem;
use std::ptr::NonNull;
use std::sync::atomic::AtomicIsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Mutex;

const NB_BUCKETS: usize = 1 << 12; // 4096
const BUCKET_MASK: u32 = (1 << 12) - 1;
Expand Down Expand Up @@ -52,7 +52,7 @@ pub(crate) static DYNAMIC_SET: Lazy<Set> = Lazy::new(|| {
impl Set {
pub(crate) fn insert(&self, string: Cow<str>, hash: u32) -> NonNull<Entry> {
let bucket_index = (hash & BUCKET_MASK) as usize;
let mut linked_list = self.buckets[bucket_index].lock();
let mut linked_list = self.buckets[bucket_index].lock().unwrap();

{
let mut ptr: Option<&mut Box<Entry>> = linked_list.as_mut();
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Set {
let value: &Entry = unsafe { &*ptr };
let bucket_index = (value.hash & BUCKET_MASK) as usize;

let mut linked_list = self.buckets[bucket_index].lock();
let mut linked_list = self.buckets[bucket_index].lock().unwrap();
debug_assert!(value.ref_count.load(SeqCst) == 0);
let mut current: &mut Option<Box<Entry>> = &mut linked_list;

Expand Down
Loading