Struct ccache::lru::LRUShared [−][src]
pub struct LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB> where
Hmap: HashMap<E, K, V, CidT, Umeta, HB>,
E: EntryT<K, V, CidT, Umeta>,
K: Hash,
V: Val,
CidT: Cid,
Umeta: Meta<V>,
HB: BuildHasher + Default, { /* fields omitted */ }
Actual implementation of the LRU on a shared hashmap
Implementations
impl<'a, Hmap: HashMap<E, K, V, CidT, Umeta, HB>, E: EntryT<K, V, CidT, Umeta>, K: Hash, V: Val, CidT: Cid, Umeta: Meta<V>, HB: BuildHasher + Default> LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>
[src]
impl<'a, Hmap: HashMap<E, K, V, CidT, Umeta, HB>, E: EntryT<K, V, CidT, Umeta>, K: Hash, V: Val, CidT: Cid, Umeta: Meta<V>, HB: BuildHasher + Default> LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>
[src]pub fn new(
entries: usize,
cache_id: CidT,
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
[src]
entries: usize,
cache_id: CidT,
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
Build a LRU that works on someone else’s hasmap
In this case each cache should have a different Cid
(Cache ID) so that
everyone known whose elements is being used, and call the proper
cache methods
pub fn set_scanf(&mut self, access_scan: Option<&'a dyn Fn(NonNull<E>)>)
[src]
change the scan callback
pub fn insert_shared(
&mut self,
hmap: &mut Hmap,
maybe_old_entry: Option<&mut E>,
new_entry_idx: usize
) -> InsertResultShared<E>
[src]
&mut self,
hmap: &mut Hmap,
maybe_old_entry: Option<&mut E>,
new_entry_idx: usize
) -> InsertResultShared<E>
insert_shared
does not actually insert anything.
It will only fix the LRU linked lists after something has been inserted by the parent.
Note that maybe_old_entry
is != None
if and only if the
ols entry is part of the same cache
pub fn clear_shared(&mut self)
[src]
reset the LRU
pub fn remove_shared(&mut self, entry: &E)
[src]
remove the pointers to this element in the LRU.
Does not actually remove the element, that is done by the caller
pub fn make_head(&mut self, entry: &mut E)
[src]
make the key the head of the LRU.
pub fn get_cache_id(&self) -> CidT
[src]
get the LRU cache id
pub fn on_get(&mut self, entry: &mut E)
[src]
Used when composing caches, run the callback on the entry
This method should be passed down between parent/child cache and only the final cache which owns the element should execute it
pub fn start_scan(&mut self)
[src]
start the lazy scan
The scan will execute on the whole LRU but only once
pub fn is_scan_running(&self) -> bool
[src]
check if the scan is still running
pub fn capacity(&self) -> usize
[src]
get the LRU capacity
pub fn len(&self) -> usize
[src]
get the LRU usage
Auto Trait Implementations
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> !RefUnwindSafe for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> !RefUnwindSafe for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> Unpin for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB> where
CidT: Unpin,
HB: Unpin,
Hmap: Unpin,
K: Unpin,
Umeta: Unpin,
V: Unpin,
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> Unpin for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB> where
CidT: Unpin,
HB: Unpin,
Hmap: Unpin,
K: Unpin,
Umeta: Unpin,
V: Unpin,
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> !UnwindSafe for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, Umeta, HB> !UnwindSafe for LRUShared<'a, Hmap, E, K, V, CidT, Umeta, HB>