CCache< T > Class Template Reference
List of all members.
Detailed Description
template<class T>
class CCache< T >
Template class
Cache implements a simple cache, where -- when the cache is full -- elements that are least used are freed from the cache. Thus for the cache to be effective one should not visit loop over objects, i.e. visit elements in order 0...num_elements (with num_elements >> the maximal number of entries in cache)
Definition at line 27 of file Cache.h.
Constructor & Destructor Documentation
template<class T>
CCache< T >::CCache |
( |
int64_t |
cache_size, |
|
|
int64_t |
obj_size, |
|
|
int64_t |
num_entries | |
|
) |
| | |
constructor
create a cache in which num_entries objects can be cached whose lookup table of sizeof(int64_t)*num_entries must fit into memory
- Parameters:
-
| cache_size | cache size in Megabytes |
| obj_size | object size |
| num_entries | number of cached objects |
Definition at line 51 of file Cache.h.
Member Function Documentation
template<class T>
bool CCache< T >::is_cached |
( |
int64_t |
number |
) |
|
checks if an object is cached
- Parameters:
-
| number | number of object to check for |
- Returns:
- if an object is cached
Definition at line 107 of file Cache.h.
template<class T>
T* CCache< T >::lock_entry |
( |
int64_t |
number |
) |
|
lock and get a cache entry
- Parameters:
-
| number | number of object to lock and get |
- Returns:
- cache entry or NULL when not cached
Definition at line 117 of file Cache.h.
template<class T>
T* CCache< T >::set_entry |
( |
int64_t |
number |
) |
|
returns the address of a free cache entry to where the data of size obj_size has to be written
- Parameters:
-
| number | number of object to unlock |
- Returns:
- address of a free cache entry
Definition at line 146 of file Cache.h.
template<class T>
void CCache< T >::unlock_entry |
( |
int64_t |
number |
) |
|
unlock a cache entry
- Parameters:
-
| number | number of object to unlock |
Definition at line 133 of file Cache.h.
Member Data Documentation
cache block
Definition at line 238 of file Cache.h.
if cache is full
Definition at line 228 of file Cache.h.
cache table containing cached objects
Definition at line 236 of file Cache.h.
size of one entry
Definition at line 230 of file Cache.h.
lookup table
Definition at line 234 of file Cache.h.
number of cache lines
Definition at line 232 of file Cache.h.
The documentation for this class was generated from the following file: