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]

pub fn new() -> Self[src]

Creates an empty SyncTable.

The hash map is initially created with a capacity of 0, so it will not allocate until it is first inserted into.

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]

Creates a LockedWrite handle from a guard protecting the underlying mutex that protects writes.

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]

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]

Gets a mutable reference to an element in the table.

Trait Implementations

impl<K: Hash + Clone, V: Clone, S: Clone + BuildHasher> Clone for SyncTable<K, V, S>[src]

impl<K, V, S: Default> Default for SyncTable<K, V, S>[src]

impl<K, V, S> Drop for SyncTable<K, V, S>[src]

impl<K: Eq + Hash + Clone + Send, V: Clone + Send, S: BuildHasher + Default> FromIterator<(K, V)> for SyncTable<K, V, S>[src]

impl<K: Send, V: Send, S: Send> Send for SyncTable<K, V, S>[src]

impl<K: Sync, V: Sync, S: Sync> Sync for SyncTable<K, V, S>[src]

Auto Trait Implementations

impl<K, V, S = RandomState> !RefUnwindSafe for SyncTable<K, V, S>

impl<K, V, S> Unpin for SyncTable<K, V, S> where
    K: Unpin,
    S: Unpin,
    V: Unpin

impl<K, V, S = RandomState> !UnwindSafe for SyncTable<K, V, S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.