From 9b62b0baceea659758880b45fc98276ca5c12e4f Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Sat, 7 Sep 2024 13:07:42 +0100 Subject: [PATCH] [sync] Update to DashMap 6 (cherry picked from commit f85462916feca9600ae24540ba5699eb8cb6fefb) --- Cargo.toml | 2 +- src/sync/base_cache.rs | 4 ++-- src/sync/cache.rs | 2 +- src/sync/iter.rs | 2 +- src/sync/mapref.rs | 22 ++++++++-------------- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b5be421..c96e74d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ tagptr = "0.2" triomphe = { version = ">=0.1.3, <0.1.12", default-features = false } # Optional dependencies (enabled by default) -dashmap = { version = "5.2", optional = true } +dashmap = { version = "6.1", optional = true } [dev-dependencies] anyhow = "1.0.19" diff --git a/src/sync/base_cache.rs b/src/sync/base_cache.rs index 1d2d200..bb03614 100644 --- a/src/sync/base_cache.rs +++ b/src/sync/base_cache.rs @@ -450,7 +450,7 @@ enum AdmissionResult { type CacheStore = dashmap::DashMap, TrioArc>, S>; -type CacheEntryRef<'a, K, V, S> = DashMapRef<'a, Arc, TrioArc>, S>; +type CacheEntryRef<'a, K, V> = DashMapRef<'a, Arc, TrioArc>>; pub(crate) struct Inner { max_capacity: Option, @@ -529,7 +529,7 @@ where } #[inline] - fn get(&self, key: &Q) -> Option> + fn get(&self, key: &Q) -> Option> where Arc: Borrow, Q: Hash + Eq + ?Sized, diff --git a/src/sync/cache.rs b/src/sync/cache.rs index 8836192..b238eaa 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -554,7 +554,7 @@ where V: 'a, S: BuildHasher + Clone, { - type Item = EntryRef<'a, K, V, S>; + type Item = EntryRef<'a, K, V>; type IntoIter = Iter<'a, K, V, S>; diff --git a/src/sync/iter.rs b/src/sync/iter.rs index f8bf65f..6d3290c 100644 --- a/src/sync/iter.rs +++ b/src/sync/iter.rs @@ -26,7 +26,7 @@ where K: Eq + Hash, S: BuildHasher + Clone, { - type Item = EntryRef<'a, K, V, S>; + type Item = EntryRef<'a, K, V>; fn next(&mut self) -> Option { for map_ref in &mut self.map_iter { diff --git a/src/sync/mapref.rs b/src/sync/mapref.rs index 0800406..8fa1411 100644 --- a/src/sync/mapref.rs +++ b/src/sync/mapref.rs @@ -1,30 +1,25 @@ use crate::common::concurrent::ValueEntry; -use std::{ - hash::{BuildHasher, Hash}, - sync::Arc, -}; +use std::{hash::Hash, sync::Arc}; use triomphe::Arc as TrioArc; -type DashMapRef<'a, K, V, S> = - dashmap::mapref::multiple::RefMulti<'a, Arc, TrioArc>, S>; +type DashMapRef<'a, K, V> = + dashmap::mapref::multiple::RefMulti<'a, Arc, TrioArc>>; -pub struct EntryRef<'a, K, V, S>(DashMapRef<'a, K, V, S>); +pub struct EntryRef<'a, K, V>(DashMapRef<'a, K, V>); -unsafe impl<'a, K, V, S> Sync for EntryRef<'a, K, V, S> +unsafe impl<'a, K, V> Sync for EntryRef<'a, K, V> where K: Eq + Hash + Send + Sync, V: Send + Sync, - S: BuildHasher, { } -impl<'a, K, V, S> EntryRef<'a, K, V, S> +impl<'a, K, V> EntryRef<'a, K, V> where K: Eq + Hash, - S: BuildHasher + Clone, { - pub(crate) fn new(map_ref: DashMapRef<'a, K, V, S>) -> Self { + pub(crate) fn new(map_ref: DashMapRef<'a, K, V>) -> Self { Self(map_ref) } @@ -41,10 +36,9 @@ where } } -impl<'a, K, V, S> std::ops::Deref for EntryRef<'a, K, V, S> +impl<'a, K, V> std::ops::Deref for EntryRef<'a, K, V> where K: Eq + Hash, - S: BuildHasher + Clone, { type Target = V;