Sharded in rustc_data_structures::sharded - Rust (original) (raw)
pub enum Sharded<T> {
Single(Lock<T>),
Shards(Box<[CacheAligned<Lock<T>>; 32]>),
}Expand description
An array of cache-line aligned inner locked structures with convenience methods. A single field is used when the compiler uses only one thread.
Variants§
Single(Lock)
Shards(Box<[CacheAligned<Lock>; 32]>)
Implementations§
impl Sharded
pub fn new(value: impl FnMut() -> T) -> Self
pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock
The shard is selected by hashing val with FxHasher.
pub fn get_shard_by_hash(&self, hash: u64) -> &Lock
pub fn get_shard_by_index(&self, i: usize) -> &Lock
pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> LockGuard<'_, T>
The shard is selected by hashing val with FxHasher.
pub fn lock_shard_by_hash(&self, hash: u64) -> LockGuard<'_, T>
pub fn lock_shard_by_index(&self, i: usize) -> LockGuard<'_, T>
pub fn lock_shards(&self) -> impl Iterator<Item = LockGuard<'_, T>>
pub fn try_lock_shards(&self) -> impl Iterator<Item = Option<LockGuard<'_, T>>>
impl<K: Eq, V> Sharded<HashTable<(K, V)>>
pub fn with_capacity(cap: usize) -> Self
pub fn len(&self) -> usize
impl<K: Eq + Hash, V> Sharded<HashTable<(K, V)>>
impl<K: Eq + Hash + Copy> Sharded<HashTable<(K, ())>>
impl<K: Eq + Hash + Copy + IntoPointer> Sharded<HashTable<(K, ())>>
pub fn contains_pointer_to<T: Hash + IntoPointer>(&self, value: &T) -> bool
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.