Detailed Description
template<class T>
class shogun::CCache< T >
Template class Cache implements a simple cache.
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 31 of file Cache.h.
List of all members.
Constructor & Destructor Documentation
default constructor
Definition at line 46 of file Cache.h.
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 68 of file Cache.h.
Member Function Documentation
virtual const char* get_name |
( |
void |
|
) |
const [virtual] |
bool 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 124 of file Cache.h.
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 134 of file Cache.h.
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 163 of file Cache.h.
void unlock_entry |
( |
int64_t |
number |
) |
|
unlock a cache entry
- Parameters:
-
| number | number of object to unlock |
Definition at line 150 of file Cache.h.
Member Data Documentation
cache block
Definition at line 259 of file Cache.h.
if cache is full
Definition at line 249 of file Cache.h.
cache table containing cached objects
Definition at line 257 of file Cache.h.
size of one entry
Definition at line 251 of file Cache.h.
lookup table
Definition at line 255 of file Cache.h.
number of cache lines
Definition at line 253 of file Cache.h.
The documentation for this class was generated from the following file: