Skip to content

Commit

Permalink
[sync] Update to DashMap 6
Browse files Browse the repository at this point in the history
(cherry picked from commit f854629)
  • Loading branch information
GnomedDev authored and tatsuya6502 committed Sep 10, 2024
1 parent 0dce5da commit 9b62b0b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/sync/base_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ enum AdmissionResult<K> {

type CacheStore<K, V, S> = dashmap::DashMap<Arc<K>, TrioArc<ValueEntry<K, V>>, S>;

type CacheEntryRef<'a, K, V, S> = DashMapRef<'a, Arc<K>, TrioArc<ValueEntry<K, V>>, S>;
type CacheEntryRef<'a, K, V> = DashMapRef<'a, Arc<K>, TrioArc<ValueEntry<K, V>>>;

pub(crate) struct Inner<K, V, S> {
max_capacity: Option<u64>,
Expand Down Expand Up @@ -529,7 +529,7 @@ where
}

#[inline]
fn get<Q>(&self, key: &Q) -> Option<CacheEntryRef<'_, K, V, S>>
fn get<Q>(&self, key: &Q) -> Option<CacheEntryRef<'_, K, V>>
where
Arc<K>: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Expand Down
2 changes: 1 addition & 1 deletion src/sync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down
2 changes: 1 addition & 1 deletion src/sync/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Item> {
for map_ref in &mut self.map_iter {
Expand Down
22 changes: 8 additions & 14 deletions src/sync/mapref.rs
Original file line number Diff line number Diff line change
@@ -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<K>, TrioArc<ValueEntry<K, V>>, S>;
type DashMapRef<'a, K, V> =
dashmap::mapref::multiple::RefMulti<'a, Arc<K>, TrioArc<ValueEntry<K, V>>>;

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)
}

Expand All @@ -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;

Expand Down

0 comments on commit 9b62b0b

Please sign in to comment.