lockable

Trait Lockable

Source
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§

Source

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?;
Source

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?;
Source

type SyncLimit<'a, OnEvictFn, E> where Self: 'a, K: 'a, V: 'a, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>

TODO Documentation

Source

type SyncLimitOwned<OnEvictFn, E> where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>

TODO Documentation

Source

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

Source

type AsyncLimitOwned<OnEvictFn, E, F> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F

TODO Documentation

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<K> Lockable<K, ()> for LockPool<K>
where K: Eq + PartialEq + Hash + Clone,

Source§

type Guard<'a> = <LockableHashMap<K, ()> as Lockable<K, ()>>::Guard<'a> where K: 'a

Source§

type OwnedGuard = <LockableHashMap<K, ()> as Lockable<K, ()>>::OwnedGuard

Source§

type SyncLimit<'a, OnEvictFn, E> = <LockableHashMap<K, ()> as Lockable<K, ()>>::SyncLimit<'a, OnEvictFn, E> where OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>, K: 'a

Source§

type SyncLimitOwned<OnEvictFn, E> = <LockableHashMap<K, ()> as Lockable<K, ()>>::SyncLimitOwned<OnEvictFn, E> where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>

Source§

type AsyncLimit<'a, OnEvictFn, E, F> = <LockableHashMap<K, ()> as Lockable<K, ()>>::AsyncLimit<'a, OnEvictFn, E, F> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F, K: 'a

Source§

type AsyncLimitOwned<OnEvictFn, E, F> = <LockableHashMap<K, ()> as Lockable<K, ()>>::AsyncLimitOwned<OnEvictFn, E, F> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F

Source§

impl<K, V> Lockable<K, V> for LockableHashMap<K, V>
where K: Eq + PartialEq + Hash + Clone,

Source§

type Guard<'a> = Guard<K, V, LockableHashMapConfig, &'a LockableMapImpl<K, V, LockableHashMapConfig>> where K: 'a, V: 'a

Source§

type OwnedGuard = Guard<K, V, LockableHashMapConfig, Arc<LockableHashMap<K, V>>>

Source§

type SyncLimit<'a, OnEvictFn, E> = SyncLimit<K, V, LockableHashMapConfig, &'a LockableMapImpl<K, V, LockableHashMapConfig>, E, OnEvictFn> where OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>, K: 'a, V: 'a

Source§

type SyncLimitOwned<OnEvictFn, E> = SyncLimit<K, V, LockableHashMapConfig, Arc<LockableHashMap<K, V>>, E, OnEvictFn> where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>

Source§

type AsyncLimit<'a, OnEvictFn, E, F> = AsyncLimit<K, V, LockableHashMapConfig, &'a LockableMapImpl<K, V, LockableHashMapConfig>, E, F, OnEvictFn> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F, K: 'a, V: 'a

Source§

type AsyncLimitOwned<OnEvictFn, E, F> = AsyncLimit<K, V, LockableHashMapConfig, Arc<LockableHashMap<K, V>>, E, F, OnEvictFn> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F

Source§

impl<K, V, Time> Lockable<K, V> for LockableLruCache<K, V, Time>
where K: Eq + PartialEq + Hash + Clone, Time: TimeProvider + Default + Clone,

Source§

type Guard<'a> = Guard<K, V, LockableLruCacheConfig<Time>, &'a LockableMapImpl<K, V, LockableLruCacheConfig<Time>>> where K: 'a, V: 'a, Time: 'a

Source§

type OwnedGuard = Guard<K, V, LockableLruCacheConfig<Time>, Arc<LockableLruCache<K, V, Time>>>

Source§

type SyncLimit<'a, OnEvictFn, E> = SyncLimit<K, V, LockableLruCacheConfig<Time>, &'a LockableMapImpl<K, V, LockableLruCacheConfig<Time>>, E, OnEvictFn> where OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> Result<(), E>, K: 'a, V: 'a, Time: 'a

Source§

type SyncLimitOwned<OnEvictFn, E> = SyncLimit<K, V, LockableLruCacheConfig<Time>, Arc<LockableLruCache<K, V, Time>>, E, OnEvictFn> where OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> Result<(), E>

Source§

type AsyncLimit<'a, OnEvictFn, E, F> = AsyncLimit<K, V, LockableLruCacheConfig<Time>, &'a LockableMapImpl<K, V, LockableLruCacheConfig<Time>>, E, F, OnEvictFn> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::Guard<'a>>) -> F, K: 'a, V: 'a, Time: 'a

Source§

type AsyncLimitOwned<OnEvictFn, E, F> = AsyncLimit<K, V, LockableLruCacheConfig<Time>, Arc<LockableLruCache<K, V, Time>>, E, F, OnEvictFn> where F: Future<Output = Result<(), E>>, OnEvictFn: FnMut(Vec<Self::OwnedGuard>) -> F