pub trait Lockable<K, V> {
type Guard<'a>
where
Self: 'a,
K: 'a,
V: 'a;
type OwnedGuard;
}Expand description
A common trait for both LockableHashMap and LockableLruCache that offers some common functionalities.
Required Associated Types
sourcetype Guard<'a>
where
Self: 'a,
K: 'a,
V: 'a
type Guard<'a>
where
Self: 'a,
K: 'a,
V: 'a
A non-owning guard holding a lock for an entry in a LockableHashMap or a LockableLruCache. This guard is created via LockableHashMap::blocking_lock, LockableHashMap::async_lock or LockableHashMap::try_lock, or the corresponding LockableLruCache methods, and its lifetime is bound to the lifetime of the LockableHashMap/LockableLruCache.
See the documentation of Guard for methods.
Examples:
use lockable::{AsyncLimit, Lockable, LockableHashMap};
let map = LockableHashMap::<usize, String>::new();
let guard: <LockableHashMap<usize, String> as Lockable<usize, String>>::Guard<'_> =
map.async_lock(1, AsyncLimit::no_limit()).await?;sourcetype OwnedGuard
type OwnedGuard
A owning guard holding a lock for an entry in a LockableHashMap or a LockableLruCache. This guard is created via LockableHashMap::blocking_lock_owned, LockableHashMap::async_lock_owned or LockableHashMap::try_lock_owned, or the corresponding LockableLruCache methods, and its lifetime is bound to the lifetime of the LockableHashMap/LockableLruCache within its Arc.
See the documentation of Guard for methods.
Examples:
use lockable::{AsyncLimit, Lockable, LockableHashMap};
use std::sync::Arc;
let map = Arc::new(LockableHashMap::<usize, String>::new());
let guard: <LockableHashMap<usize, String> as Lockable<usize, String>>::OwnedGuard =
map.async_lock_owned(1, AsyncLimit::no_limit()).await?;