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]

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]

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]

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]

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> !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> 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>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,