Struct ccache::swtlfu::SWTLFUShared [−][src]
pub struct SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> where
Hmap: HashMap<E, K, V, CidCtr, Umeta, HB>,
E: EntryT<K, V, CidCtr, Umeta>,
K: Hash,
V: Val,
CidT: Cid,
CidCtr: CidCounter<CidT>,
Umeta: Meta<V>,
HB: BuildHasher + Default, { /* fields omitted */ }
Actual implementation of the Shared Scan-Window-Tiny-LFU
Note that no elements get actually added ot removed to the hashmap here, we only fix the various sub-caches and track all counters.
Just like LRU and SLRU the actual adding/deletion must be done by the caller
Implementations
impl<'a, Hmap: HashMap<E, K, V, CidCtr, Umeta, HB> + 'a, E: EntryT<K, V, CidCtr, Umeta> + 'a, K: Hash + 'a, V: Val + 'a, CidT: Cid + 'a, CidCtr: CidCounter<CidT> + 'a, Umeta: Meta<V> + 'a, HB: BuildHasher + Default + 'a> SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
[src]
impl<'a, Hmap: HashMap<E, K, V, CidCtr, Umeta, HB> + 'a, E: EntryT<K, V, CidCtr, Umeta> + 'a, K: Hash + 'a, V: Val + 'a, CidT: Cid + 'a, CidCtr: CidCounter<CidT> + 'a, Umeta: Meta<V> + 'a, HB: BuildHasher + Default + 'a> SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
[src]pub fn new_standard(
window_cid: CidT,
probation_cid: CidT,
protected_cid: CidT,
entries: usize,
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
[src]
window_cid: CidT,
probation_cid: CidT,
protected_cid: CidT,
entries: usize,
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
Build a Scan W-TLFU with standard split between the caches
can be given an optional callback for a user-run-scan
pub fn new(
window: (usize, CidT),
probation: (usize, CidT),
protected: (usize, CidT),
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
[src]
window: (usize, CidT),
probation: (usize, CidT),
protected: (usize, CidT),
access_scan: Option<&'a dyn Fn(NonNull<E>)>
) -> Self
Build a Scan W-TLFU with a custom split between the cacnes
can be given an optional callback for a user-run-scan
pub fn set_scanf(&mut self, access_scan: Option<&'a dyn Fn(NonNull<E>)>)
[src]
change the user scan function
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>
An element has been added by the caller, fix the various sub-caches
Note that maybe_old_entry
is != None
only if the clash happened in
this cache
pub fn clear_shared(&mut self)
[src]
reset the cache
pub fn remove_shared(&mut self, entry: &E)
[src]
fix the sub-caches so that it is safe to remove from the hashmap
pub fn get_cache_ids(&self) -> [CidT; 3]
[src]
return the cache ids, in order:
- Window
- probatory
- protected
pub fn on_get(&mut self, entry: &mut E)
[src]
if a higher-level cache is using this one, call this to make sure that the right cache will handle the on-get callback
pub fn start_scan(&mut self)
[src]
start the user-scan
Note: It will run once, but while it will stop at the last element, it
is not guaranteed that it will start from the first
This meas that this will very probably never scan all elements unless
you keep reissuing it after it has stopped
pub fn is_scan_running(&self) -> bool
[src]
check if the scan is running
pub fn capacity(&self) -> usize
[src]
get the cache max capacity
pub fn len(&self) -> usize
[src]
get the current elements in the cache
Auto Trait Implementations
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !RefUnwindSafe for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !RefUnwindSafe for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !Send for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !Send for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !Sync for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !Sync for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> Unpin for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> where
CidCtr: Unpin,
CidT: Unpin,
E: Unpin,
HB: Unpin,
Hmap: Unpin,
K: Unpin,
Umeta: Unpin,
V: Unpin,
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> Unpin for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> where
CidCtr: Unpin,
CidT: Unpin,
E: Unpin,
HB: Unpin,
Hmap: Unpin,
K: Unpin,
Umeta: Unpin,
V: Unpin,
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !UnwindSafe for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>
impl<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB> !UnwindSafe for SWTLFUShared<'a, Hmap, E, K, V, CidT, CidCtr, Umeta, HB>