LibreOffice Module stoc (master) 1
|
Implementation of a least recently used (lru) cache. More...
#include <lrucache.hxx>
Classes | |
struct | CacheEntry |
Public Member Functions | |
LRU_Cache () | |
Constructor: More... | |
t_Val | getValue (const t_Key &rKey) const |
Retrieves a value from the cache. More... | |
void | setValue (const t_Key &rKey, const t_Val &rValue) |
Sets a value to be cached for given key. More... | |
void | clear () |
Clears the cache, thus releasing all cached elements and keys. More... | |
Private Types | |
typedef std::unordered_map< t_Key, CacheEntry *, t_KeyHash > | t_Key2Element |
Private Member Functions | |
void | toFront (CacheEntry *pEntry) const |
Private Attributes | |
std::mutex | _aCacheMutex |
sal_Int32 | _nCachedElements |
t_Key2Element | _aKey2Element |
std::unique_ptr< CacheEntry[]> | _pBlock |
CacheEntry * | _pHead |
CacheEntry * | _pTail |
Implementation of a least recently used (lru) cache.
Definition at line 37 of file lrucache.hxx.
|
private |
Definition at line 46 of file lrucache.hxx.
|
inlineexplicit |
Constructor:
nCachedElements | number of elements to be cached; default param set to 128 |
Definition at line 84 of file lrucache.hxx.
References nPos, and LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::pPred.
|
inline |
Clears the cache, thus releasing all cached elements and keys.
Definition at line 185 of file lrucache.hxx.
References nPos, and SAL_INFO.
Referenced by stoc_corefl::IdlReflectionServiceImpl::disposing().
|
inline |
Retrieves a value from the cache.
Returns default constructed value, if none was found.
rKey | a key |
Definition at line 127 of file lrucache.hxx.
References LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::aKey, LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::aVal, and SAL_INFO.
Referenced by stoc_corefl::IdlReflectionServiceImpl::forName(), stoc_corefl::IdlReflectionServiceImpl::forType(), and stoc_corefl::IdlReflectionServiceImpl::getByHierarchicalName().
|
inline |
Sets a value to be cached for given key.
rKey | a key |
rValue | a value |
Definition at line 146 of file lrucache.hxx.
References LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::aKey, LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::aVal, and SAL_INFO.
Referenced by stoc_corefl::IdlReflectionServiceImpl::forName(), stoc_corefl::IdlReflectionServiceImpl::forType(), and stoc_corefl::IdlReflectionServiceImpl::getByHierarchicalName().
|
inlineprivate |
Definition at line 105 of file lrucache.hxx.
References LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::pPred, and LRU_Cache< t_Key, t_Val, t_KeyHash >::CacheEntry::pSucc.
|
mutableprivate |
Definition at line 48 of file lrucache.hxx.
|
private |
Definition at line 50 of file lrucache.hxx.
|
private |
Definition at line 49 of file lrucache.hxx.
|
private |
Definition at line 52 of file lrucache.hxx.
|
mutableprivate |
Definition at line 53 of file lrucache.hxx.
|
mutableprivate |
Definition at line 54 of file lrucache.hxx.