Struct horde::sync_table::SyncTable [−][src]
pub struct SyncTable<K, V, S = DefaultHashBuilder> { /* fields omitted */ }
A hash table with lock-free reads.
It is based on the table from the hashbrown
crate.
Implementations
impl<K, V> SyncTable<K, V, DefaultHashBuilder>
[src]
impl<K, V> SyncTable<K, V, DefaultHashBuilder>
[src]impl<K, V, S> SyncTable<K, V, S>
[src]
impl<K, V, S> SyncTable<K, V, S>
[src]pub fn new_with(hash_builder: S, capacity: usize) -> Self
[src]
Creates an empty SyncTable with the specified capacity, using hash_builder
to hash the elements or keys.
The hash map will be able to hold at least capacity
elements without
reallocating. If capacity
is 0, the hash map will not allocate.
pub fn hasher(&self) -> &S
[src]
Returns a reference to the table’s BuildHasher
.
pub fn mutex(&self) -> &Mutex<()>
[src]
Gets a reference to the underlying mutex that protects writes.
pub fn read<'a>(&'a self, pin: Pin<'a>) -> Read<'a, K, V, S>
[src]
Creates a Read handle from a pinned region.
Use crate::collect::pin to get a Pin
instance.
pub unsafe fn unsafe_write(&self) -> Write<'_, K, V, S>
[src]
Creates a Write handle without checking for exclusive access.
Safety
It’s up to the caller to ensure only one thread writes to the vector at a time.
pub fn write(&mut self) -> Write<'_, K, V, S>
[src]
Creates a Write handle from a mutable reference.
pub fn lock(&self) -> LockedWrite<'_, K, V, S>
[src]
Creates a LockedWrite handle by taking the underlying mutex that protects writes.
pub fn lock_from_guard<'a>(
&'a self,
guard: MutexGuard<'a, ()>
) -> LockedWrite<'a, K, V, S>
[src]
&'a self,
guard: MutexGuard<'a, ()>
) -> LockedWrite<'a, K, V, S>
Creates a LockedWrite handle from a guard protecting the underlying mutex that protects writes.
impl<K, V, S: BuildHasher> SyncTable<K, V, S>
[src]
impl<K, V, S: BuildHasher> SyncTable<K, V, S>
[src]pub fn hash_key<Q: ?Sized>(&self, key: &Q) -> u64 where
K: Borrow<Q>,
Q: Hash,
[src]
K: Borrow<Q>,
Q: Hash,
Hashes a key with the table’s hasher.
pub fn get_mut<Q: ?Sized>(
&mut self,
key: &Q,
hash: Option<u64>
) -> Option<(&mut K, &mut V)> where
K: Borrow<Q>,
Q: Eq + Hash,
[src]
&mut self,
key: &Q,
hash: Option<u64>
) -> Option<(&mut K, &mut V)> where
K: Borrow<Q>,
Q: Eq + Hash,
Gets a mutable reference to an element in the table.
Trait Implementations
Auto Trait Implementations
impl<K, V, S = RandomState> !RefUnwindSafe for SyncTable<K, V, S>
impl<K, V, S = RandomState> !RefUnwindSafe for SyncTable<K, V, S>
impl<K, V, S = RandomState> !UnwindSafe for SyncTable<K, V, S>
impl<K, V, S = RandomState> !UnwindSafe for SyncTable<K, V, S>