[−][src]Struct storage_map::StorageMap
StorageMap
is a wrapper around HashMap
that allows efficient concurrent
access for the use case when only rarely the missing elements need to be created.
Methods
impl<L, K, V, S> StorageMap<L, HashMap<K, V, S>> where
L: RawRwLock,
K: Clone + Eq + Hash,
S: BuildHasher,
[src]
L: RawRwLock,
K: Clone + Eq + Hash,
S: BuildHasher,
pub fn with_hasher(hash_builder: S) -> Self
[src]
Create a new storage map with the given hasher.
pub fn get_or_create_with<'a, F: FnOnce() -> V>(
&'a self,
key: &K,
create_fn: F
) -> StorageMapGuard<'a, L, V>
[src]
&'a self,
key: &K,
create_fn: F
) -> StorageMapGuard<'a, L, V>
Get a value associated with the key. The method assumes that more often then not the value is already there. If it's not - the closure will be called to create one. This closure is expected to always produce the same value given the same key.
pub fn prepare_maybe<F: FnOnce() -> Option<V>>(
&self,
key: &K,
create_fn: F
) -> PrepareResult
[src]
&self,
key: &K,
create_fn: F
) -> PrepareResult
Make sure the given key is in the map, as a way to warm up future run-time access to the map at the initialization stage.
pub fn whole_write(&self) -> WholeMapWriteGuard<L, HashMap<K, V, S>>
[src]
Lock the whole map for writing.
Trait Implementations
impl<L: Sync, M> Sync for StorageMap<L, M>
[src]
impl<L: RawRwLock, M: Default> Default for StorageMap<L, M>
[src]
impl<L: Send, M> Send for StorageMap<L, M>
[src]
impl<L, M: Debug> Debug for StorageMap<L, M>
[src]
Auto Trait Implementations
impl<L, M> Unpin for StorageMap<L, M> where
L: Unpin,
M: Unpin,
L: Unpin,
M: Unpin,
impl<L, M> !RefUnwindSafe for StorageMap<L, M>
impl<L, M> UnwindSafe for StorageMap<L, M> where
L: UnwindSafe,
M: UnwindSafe,
L: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,