pub struct HashTrie<K, V> where
K: Hash + Eq + Clone + Debug + Sync + Send + 'static,
V: Clone + Sync + Send + 'static, { /* private fields */ }
Expand description
A concurrently readable map based on a modified Trie.
This is a concurrently readable structure, meaning it has transactional properties. Writers are serialised (one after the other), and readers can exist in parallel with stable views of the structure at a point in time.
This is achieved through the use of COW or MVCC. As a write occurs subsets of the tree are cloned into the writer thread and then commited later. This may cause memory usage to increase in exchange for a gain in concurrent behaviour.
Transactions can be rolled-back (aborted) without penalty by dropping
the HashTrieWriteTxn
without calling commit()
.
Implementations
sourceimpl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> HashTrie<K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> HashTrie<K, V>
sourcepub async fn read<'x>(&'x self) -> HashTrieReadTxn<'x, K, V>
pub async fn read<'x>(&'x self) -> HashTrieReadTxn<'x, K, V>
Initiate a read transaction for the Hashmap, concurrent to any other readers or writers.
sourcepub async fn write<'x>(&'x self) -> HashTrieWriteTxn<'x, K, V>
pub async fn write<'x>(&'x self) -> HashTrieWriteTxn<'x, K, V>
Initiate a write transaction for the map, exclusive to this writer, and concurrently to all existing reads.
sourcepub fn try_write(&self) -> Option<HashTrieWriteTxn<'_, K, V>>
pub fn try_write(&self) -> Option<HashTrieWriteTxn<'_, K, V>>
Attempt to create a new write, returns None if another writer already exists.
Trait Implementations
sourceimpl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Default for HashTrie<K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Default for HashTrie<K, V>
sourceimpl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> FromIterator<(K, V)> for HashTrie<K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> FromIterator<(K, V)> for HashTrie<K, V>
sourcefn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Send for HashTrie<K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Sync for HashTrie<K, V>
Auto Trait Implementations
impl<K, V> !RefUnwindSafe for HashTrie<K, V>
impl<K, V> Unpin for HashTrie<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for HashTrie<K, V> where
K: UnwindSafe + RefUnwindSafe,
V: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more