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§

Source§

impl Sharded

Source

pub fn new(value: impl FnMut() -> T) -> Self

Source

pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock

The shard is selected by hashing val with FxHasher.

Source

pub fn get_shard_by_hash(&self, hash: u64) -> &Lock

Source

pub fn get_shard_by_index(&self, i: usize) -> &Lock

Source

pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> LockGuard<'_, T>

The shard is selected by hashing val with FxHasher.

Source

pub fn lock_shard_by_hash(&self, hash: u64) -> LockGuard<'_, T>

Source

pub fn lock_shard_by_index(&self, i: usize) -> LockGuard<'_, T>

Source

pub fn lock_shards(&self) -> impl Iterator<Item = LockGuard<'_, T>>

Source

pub fn try_lock_shards(&self) -> impl Iterator<Item = Option<LockGuard<'_, T>>>

Source§

impl<K: Eq, V> Sharded<HashTable<(K, V)>>

Source

pub fn with_capacity(cap: usize) -> Self

Source

pub fn len(&self) -> usize

Source§

impl<K: Eq + Hash, V> Sharded<HashTable<(K, V)>>

Source§

impl<K: Eq + Hash + Copy> Sharded<HashTable<(K, ())>>

Source§

impl<K: Eq + Hash + Copy + IntoPointer> Sharded<HashTable<(K, ())>>

Source

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.