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

refactor(s2n-quic-dc): put map impl behind trait #2361

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
8 changes: 5 additions & 3 deletions dc/s2n-quic-dc/src/fixed_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ use core::{
hash::Hash,
sync::atomic::{AtomicU8, Ordering},
};
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard};
use parking_lot::{RwLock, RwLockReadGuard, RwLockUpgradableReadGuard};
use std::{collections::hash_map::RandomState, hash::BuildHasher};

pub use parking_lot::MappedRwLockReadGuard as ReadGuard;

pub struct Map<K, V, S = RandomState> {
slots: Box<[Slot<K, V>]>,
hash_builder: S,
Expand Down Expand Up @@ -94,7 +96,7 @@ where
self.get_by_key(key).is_some()
}

pub fn get_by_key(&self, key: &K) -> Option<MappedRwLockReadGuard<'_, V>> {
pub fn get_by_key(&self, key: &K) -> Option<ReadGuard<'_, V>> {
self.slot_by_hash(key).get_by_key(key)
}
}
Expand Down Expand Up @@ -148,7 +150,7 @@ where
None
}

fn get_by_key(&self, needle: &K) -> Option<MappedRwLockReadGuard<'_, V>> {
fn get_by_key(&self, needle: &K) -> Option<ReadGuard<'_, V>> {
// Scan each value and check if our requested needle is present.
let values = self.values.read();
for (value_idx, value) in values.iter().enumerate() {
Expand Down
Loading
Loading