Struct CHashMap

Source
pub struct CHashMap<K, T, S = DefaultHashBuilder> { /* private fields */ }

Implementations§

Source§

impl<K, T> CHashMap<K, T, DefaultHashBuilder>

Source

pub fn new(num_shards: usize) -> Self

Source§

impl<K, T, S> CHashMap<K, T, S>
where S: Clone,

Source

pub fn with_hasher(num_shards: usize, hash_builder: S) -> Self

Source§

impl<K, T, S> CHashMap<K, T, S>
where K: Clone, T: Clone, S: Clone,

Source

pub async fn duplicate(&self) -> Self

Duplicates/Clones the CHashMap. A CHashMap cannot be cloned regularly due to internal async locking.

Source§

impl<K, T, S> CHashMap<K, T, S>
where K: Hash + Eq, S: BuildHasher,

Source

pub fn hash_builder(&self) -> &S

Source

pub async fn clear(&self)

Source

pub async fn retain<F>(&self, f: F)
where F: Fn(&K, &mut T) -> bool,

Source

pub fn iter_shards<'a>( &'a self, ) -> impl Iterator<Item = &'a RwLock<Shard<K, T, S>>>

Source

pub fn size(&self) -> usize

Source

pub fn num_shards(&self) -> usize

Source

pub fn try_maybe_contains_hash(&self, hash: u64) -> bool

Source

pub async fn contains_hash(&self, hash: u64) -> bool

Source

pub async fn contains<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub async fn remove<Q>(&self, key: &Q) -> Option<T>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub async fn insert(&self, key: K, value: T) -> Option<T>

Source

pub async fn get<Q>(&self, key: &Q) -> Option<ReadHandle<impl Erased, T>>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub async fn get_cloned<Q>(&self, key: &Q) -> Option<T>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized, T: Clone,

Source

pub async fn get_mut<Q>(&self, key: &Q) -> Option<WriteHandle<impl Erased, T>>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub async fn get_or_insert( &self, key: &K, on_insert: impl FnOnce() -> T, ) -> ReadHandle<impl Erased, T>
where K: Clone,

Source

pub async fn get_mut_or_insert( &self, key: &K, on_insert: impl FnOnce() -> T, ) -> WriteHandle<impl Erased, T>
where K: Clone,

Source

pub async fn get_or_default(&self, key: &K) -> ReadHandle<impl Erased, T>
where K: Clone, T: Default,

Source

pub async fn get_mut_or_default(&self, key: &K) -> WriteHandle<impl Erased, T>
where K: Clone, T: Default,

Source

pub async fn batch_read<'a, Q, I, F>( &self, keys: I, cache: Option<&mut Vec<(&'a Q, u64, usize)>>, f: F, )
where K: Borrow<Q>, Q: Hash + Eq + 'a + ?Sized, I: IntoIterator<Item = &'a Q>, F: FnMut(&'a Q, Option<(&K, &T)>),

Aggregates all the provided keys and batches together access to the underlying shards, reducing locking overhead at the cost of memory to buffer keys/hashes.

Source

pub async fn batch_write<'a, Q, I, F>( &self, keys: I, cache: Option<&mut Vec<(&'a Q, u64, usize)>>, f: F, )
where K: Borrow<Q>, Q: Hash + Eq + 'a + ?Sized, I: IntoIterator<Item = &'a Q>, F: FnMut(&'a Q, RawEntryMut<'_, K, T, S>),

Aggregates all the provided keys and batches together access to the underlying shards, reducing locking overhead at the cost of memory to buffer keys/hashes

Trait Implementations§

Source§

impl<K: Debug, T: Debug, S: Debug> Debug for CHashMap<K, T, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, T> Default for CHashMap<K, T, DefaultHashBuilder>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, T, S = BuildHasherDefault<AHasher>> !Freeze for CHashMap<K, T, S>

§

impl<K, T, S = BuildHasherDefault<AHasher>> !RefUnwindSafe for CHashMap<K, T, S>

§

impl<K, T, S> Send for CHashMap<K, T, S>
where S: Send + Sync, K: Send + Sync, T: Send + Sync,

§

impl<K, T, S> Sync for CHashMap<K, T, S>
where S: Sync + Send, K: Send + Sync, T: Send + Sync,

§

impl<K, T, S> Unpin for CHashMap<K, T, S>
where S: Unpin,

§

impl<K, T, S = BuildHasherDefault<AHasher>> !UnwindSafe for CHashMap<K, T, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V