pub trait Lockable<K, V> {
type Guard<'a>
where Self: 'a,
K: 'a,
V: 'a;
type OwnedGuard;
type SyncLimit<'a, OnEvictFn, E>
where Self: 'a,
K: 'a,
V: 'a,
OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>;
type SyncLimitOwned<OnEvictFn, E>
where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>;
type AsyncLimit<'a, OnEvictFn, E, F>
where Self: 'a,
K: 'a,
V: 'a,
F: Future<Output = Result<(), E>>,
OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F;
type AsyncLimitOwned<OnEvictFn, E, F>
where F: Future<Output = Result<(), E>>,
OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F;
}
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?;
sourcetype SyncLimit<'a, OnEvictFn, E>
where
Self: 'a,
K: 'a,
V: 'a,
OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>
type SyncLimit<'a, OnEvictFn, E> where Self: 'a, K: 'a, V: 'a, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>
TODO Documentation
sourcetype SyncLimitOwned<OnEvictFn, E>
where
OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>
type SyncLimitOwned<OnEvictFn, E> where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>
TODO Documentation
sourcetype AsyncLimit<'a, OnEvictFn, E, F>
where
Self: 'a,
K: 'a,
V: 'a,
F: Future<Output = Result<(), E>>,
OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F
type AsyncLimit<'a, OnEvictFn, E, F> where Self: 'a, K: 'a, V: 'a, F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F
TODO Documentation
sourcetype AsyncLimitOwned<OnEvictFn, E, F>
where
F: Future<Output = Result<(), E>>,
OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F
type AsyncLimitOwned<OnEvictFn, E, F> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F
TODO Documentation