Skip to content

Commit

Permalink
avoid using parking_lot now that we have bumped the MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
droundy committed Apr 12, 2024
1 parent 7921f33 commit 08c4c53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ maintenance = { status = "actively-developed" }

[dependencies]

parking_lot = "0.12.1"
ahash = { version = "0.8.5", optional = true }
dashmap = { version = "5.4.0", optional = true }
once_cell = { version = "1.4", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions src/arena.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![deny(missing_docs)]
use crate::boxedset::HashSet;
use parking_lot::Mutex;
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::sync::Mutex;

/// A arena for storing interned data
///
Expand Down Expand Up @@ -71,7 +71,7 @@ impl<T: Eq + Hash> Arena<T> {
/// allocate a spot for the value on the heap. Otherwise, it will return a
/// pointer to the object previously allocated.
pub fn intern(&self, val: T) -> ArenaIntern<T> {
let mut m = self.data.lock();
let mut m = self.data.lock().unwrap();
if let Some(b) = m.get(&val) {
let p = b.as_ref() as *const T;
return ArenaIntern {
Expand All @@ -94,7 +94,7 @@ impl<T: Eq + Hash + ?Sized> Arena<T> {
Box<T>: From<&'b I>,
I: Eq + std::hash::Hash + ?Sized,
{
let mut m = self.data.lock();
let mut m = self.data.lock().unwrap();
if let Some(b) = m.get(val) {
let p = b.as_ref() as *const T;
return ArenaIntern {
Expand All @@ -113,7 +113,7 @@ impl<T: Eq + Hash + ?Sized> Arena<T> {
Box<T>: From<I>,
I: Eq + std::hash::Hash + AsRef<T>,
{
let mut m = self.data.lock();
let mut m = self.data.lock().unwrap();
if let Some(b) = m.get(val.as_ref()) {
let p = b.as_ref() as *const T;
return ArenaIntern {
Expand Down Expand Up @@ -346,7 +346,7 @@ impl<T: Eq + Hash + ?Sized> Arena<T> {
T: 'a + Borrow<I> + From<&'b I>,
I: Eq + std::hash::Hash + ?Sized,
{
let mut m = self.data.lock();
let mut m = self.data.lock().unwrap();
if let Some(b) = m.get(val) {
let p = b.as_ref() as *const T;
return ArenaIntern {
Expand Down
5 changes: 3 additions & 2 deletions src/container.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use parking_lot::Mutex;
use std::any::Any;
use std::any::TypeId;
use std::hash::{Hash, Hasher};
use std::sync::Mutex;

pub struct TypeHolderSend(Vec<AnySend>);

Expand Down Expand Up @@ -33,7 +33,7 @@ pub struct Arena {

impl Arena {
pub const fn new() -> Self {
const EMPTY: Mutex<TypeHolderSend> = parking_lot::const_mutex(TypeHolderSend::new());
const EMPTY: Mutex<TypeHolderSend> = Mutex::new(TypeHolderSend::new());
Arena {
containers: [EMPTY; INTERN_CONTAINER_COUNT],
}
Expand Down Expand Up @@ -82,6 +82,7 @@ impl Arena {
f(
self.containers[hash_of_type::<T>() as usize % INTERN_CONTAINER_COUNT]
.lock()
.unwrap()
.get_type_mut(),
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/typearena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ where
use core::ops::DerefMut;
for v in CONTAINERS[hash_of_type::<T>() % CONTAINER_COUNT].iter() {
if let Some(m) = v.0.downcast_ref::<Mutex<HashSet<T>>>() {
let mut m = m.lock();
let mut m = m.lock().unwrap();
return f(m.deref_mut());
}
}
Expand All @@ -67,7 +67,7 @@ where
// different type.
for v in CONTAINERS[hash_of_type::<T>() % CONTAINER_COUNT].iter() {
if let Some(m) = v.0.downcast_ref::<Mutex<HashSet<T>>>() {
let mut m = m.lock();
let mut m = m.lock().unwrap();
return f(m.deref_mut());
}
}
Expand All @@ -76,11 +76,11 @@ where

use super::boxedset;
use boxedset::HashSet;
use parking_lot::Mutex;
use std::borrow::Borrow;
use std::convert::AsRef;
use std::fmt::{Debug, Display, Pointer};
use std::ops::Deref;
use std::sync::Mutex;

#[cfg(feature = "serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand Down

0 comments on commit 08c4c53

Please sign in to comment.