#include <Cache.h>
The _EvictFcn is required to implement the signature:
void (*)(_Key& k, _Val& v);
Definition at line 38 of file Cache.h.
Public Types | |
typedef LRUList < LRUListEnt > | CacheList |
typedef std::map < _Key, typename CacheList::iterator > | CacheMap |
Public Member Functions | |
Cache (const char *logpath, size_t max) | |
bool | get (const _Key &key, _Val *valp, bool pin=false, typename CacheList::iterator *iter=NULL) |
bool | get_and_pin (const _Key &key, _Val *valp) |
void | unpin (const _Key &key) |
bool | put_and_pin (const _Key &key, const _Val &val, typename CacheList::iterator *iter=NULL) |
void | evict (const _Key &key) |
void | evict_all () |
Private Member Functions | |
bool | evict_last () |
Private Attributes | |
SpinLock | lock_ |
CacheList | cache_list_ |
CacheMap | cache_map_ |
size_t | max_ |
Classes | |
struct | LRUListEnt |
class | ScopedUnpin |
typedef LRUList<LRUListEnt> oasys::Cache< _Key, _Val, _EvictFcn >::CacheList |
typedef std::map<_Key, typename CacheList::iterator> oasys::Cache< _Key, _Val, _EvictFcn >::CacheMap |
oasys::Cache< _Key, _Val, _EvictFcn >::Cache | ( | const char * | logpath, | |
size_t | max | |||
) | [inline] |
bool oasys::Cache< _Key, _Val, _EvictFcn >::get | ( | const _Key & | key, | |
_Val * | valp, | |||
bool | pin = false , |
|||
typename CacheList::iterator * | iter = NULL | |||
) | [inline] |
Get an item from the cache and optionally pin it.
Definition at line 70 of file Cache.h.
References oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, ExamineDump::l, oasys::Cache< _Key, _Val, _EvictFcn >::lock_, log_debug, and oasys::LRUList< _Type >::move_to_back().
bool oasys::Cache< _Key, _Val, _EvictFcn >::get_and_pin | ( | const _Key & | key, | |
_Val * | valp | |||
) | [inline] |
void oasys::Cache< _Key, _Val, _EvictFcn >::unpin | ( | const _Key & | key | ) | [inline] |
Unpin the val referenced by _Key.
Definition at line 113 of file Cache.h.
References ASSERT, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, ExamineDump::l, oasys::Cache< _Key, _Val, _EvictFcn >::lock_, and log_debug.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::ScopedUnpin::~ScopedUnpin().
bool oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin | ( | const _Key & | key, | |
const _Val & | val, | |||
typename CacheList::iterator * | iter = NULL | |||
) | [inline] |
Put an val in the file cache which may evict unpinned vals. Also pin the val that was just put into the cache.
Definition at line 135 of file Cache.h.
References oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, oasys::Cache< _Key, _Val, _EvictFcn >::evict_last(), ExamineDump::l, oasys::Cache< _Key, _Val, _EvictFcn >::lock_, log_debug, and oasys::Cache< _Key, _Val, _EvictFcn >::max_.
void oasys::Cache< _Key, _Val, _EvictFcn >::evict | ( | const _Key & | key | ) | [inline] |
Evict the given key, calling the _EvictFcn on it.
Definition at line 176 of file Cache.h.
References ASSERT, oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, ExamineDump::l, oasys::Cache< _Key, _Val, _EvictFcn >::lock_, and log_debug.
void oasys::Cache< _Key, _Val, _EvictFcn >::evict_all | ( | ) | [inline] |
Evict all of the cached vals.
Definition at line 201 of file Cache.h.
References oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, ExamineDump::l, oasys::Cache< _Key, _Val, _EvictFcn >::lock_, log_debug, and log_warn.
bool oasys::Cache< _Key, _Val, _EvictFcn >::evict_last | ( | ) | [inline, private] |
Search from the beginning of the list and throw out a single, unpinned val.
Definition at line 259 of file Cache.h.
References oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_, oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_, log_debug, and log_warn.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin().
SpinLock oasys::Cache< _Key, _Val, _EvictFcn >::lock_ [private] |
Definition at line 246 of file Cache.h.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::evict(), oasys::Cache< _Key, _Val, _EvictFcn >::evict_all(), oasys::Cache< _Key, _Val, _EvictFcn >::get(), oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin(), and oasys::Cache< _Key, _Val, _EvictFcn >::unpin().
CacheList oasys::Cache< _Key, _Val, _EvictFcn >::cache_list_ [private] |
Definition at line 248 of file Cache.h.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::evict(), oasys::Cache< _Key, _Val, _EvictFcn >::evict_all(), oasys::Cache< _Key, _Val, _EvictFcn >::evict_last(), oasys::Cache< _Key, _Val, _EvictFcn >::get(), and oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin().
CacheMap oasys::Cache< _Key, _Val, _EvictFcn >::cache_map_ [private] |
Definition at line 249 of file Cache.h.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::evict(), oasys::Cache< _Key, _Val, _EvictFcn >::evict_all(), oasys::Cache< _Key, _Val, _EvictFcn >::evict_last(), oasys::Cache< _Key, _Val, _EvictFcn >::get(), oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin(), and oasys::Cache< _Key, _Val, _EvictFcn >::unpin().
size_t oasys::Cache< _Key, _Val, _EvictFcn >::max_ [private] |
Definition at line 251 of file Cache.h.
Referenced by oasys::Cache< _Key, _Val, _EvictFcn >::put_and_pin().