pub struct AsyncShardedHashMap<K, V, S = FxBuildHasher>where
K: Eq + Hash + Clone + Send + Sync,
V: Clone + Send + Sync,
S: BuildHasher + Clone + Send + Sync,{ /* private fields */ }Available on crate feature
async only.Expand description
Asynchronous sharded concurrent HashMap (Tokio RwLock).
Implementations§
Source§impl<K, V> AsyncShardedHashMap<K, V, FxBuildHasher>
impl<K, V> AsyncShardedHashMap<K, V, FxBuildHasher>
Source§impl<K, V, S> AsyncShardedHashMap<K, V, S>
impl<K, V, S> AsyncShardedHashMap<K, V, S>
Sourcepub fn with_shards_and_hasher(shard_count: usize, hasher: S) -> Self
pub fn with_shards_and_hasher(shard_count: usize, hasher: S) -> Self
Create with custom hasher.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Configured shard capacity.
Sourcepub async fn initialized_shards(&self) -> usize
pub async fn initialized_shards(&self) -> usize
Number of initialized shards.
Sourcepub async fn get(&self, key: &K) -> Option<V>
pub async fn get(&self, key: &K) -> Option<V>
Get cloned value; uses try_read first (fast path, reduces scheduler churn).
Sourcepub async fn iter(&self) -> Vec<(K, V)>
pub async fn iter(&self) -> Vec<(K, V)>
Snapshot iteration (async).
Steps:
- Snapshot Arc list of initialized shards under read lock of the shard vector.
- For each shard: try
try_read; fallback toawaitread. - Clone inner HashMaps (short critical sections).
- If
rayonenabled, parallel flatten of snapshots.
Returns a materialized Vec.
Trait Implementations§
Source§impl<K, V, S> Clone for AsyncShardedHashMap<K, V, S>
impl<K, V, S> Clone for AsyncShardedHashMap<K, V, S>
Source§fn clone(&self) -> AsyncShardedHashMap<K, V, S>
fn clone(&self) -> AsyncShardedHashMap<K, V, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<K, V, S> Freeze for AsyncShardedHashMap<K, V, S>where
S: Freeze,
impl<K, V, S = BuildHasherDefault<FxHasher>> !RefUnwindSafe for AsyncShardedHashMap<K, V, S>
impl<K, V, S> Send for AsyncShardedHashMap<K, V, S>
impl<K, V, S> Sync for AsyncShardedHashMap<K, V, S>
impl<K, V, S> Unpin for AsyncShardedHashMap<K, V, S>where
S: Unpin,
impl<K, V, S = BuildHasherDefault<FxHasher>> !UnwindSafe for AsyncShardedHashMap<K, V, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more