|
ISLEman
|
Cache for objects. More...
#include <objcache.h>
Public Member Functions | |
| ObjCache (unsigned int logSize) | |
| ~ObjCache () | |
| int | add (void *obj, void **victim) |
| void | use (int handle) |
| void | del (int handle) |
| void | printLRU () |
| void | printStats () |
| int | size () const |
| int | count () const |
| int | hits () const |
| int | misses () const |
Cache for objects.
This cache is used to decide which objects should remain in memory. It uses a least recently used policy (LRU) to decide which object should make room for a new object when the cache is full. An object should be added using add(), and then use() should be called when the object is used.
| ObjCache::ObjCache | ( | unsigned int | logSize | ) |
Creates the cache. The number of elements in the cache is 2 to the power of logSize.
| ObjCache::~ObjCache | ( | ) |
Deletes the cache and free all internal data-structures used.
| int ObjCache::add | ( | void * | obj, |
| void ** | victim | ||
| ) |
Adds obj to the cache. When victim is not null, this object is removed from the cache to make room for obj. Returns a handle to the object, which can be used by the use() function, each time the object is used.
|
inline |
number of elements in the cache
| void ObjCache::del | ( | int | handle | ) |
Removes the item identified by handle from the cache.
| void ObjCache::printLRU | ( | ) |
Debug function. Prints the LRU list
| void ObjCache::printStats | ( | ) |
Print miss/hits statistics
|
inline |
total size of the cache
|
inline |
Indicates that this object is used. This will move the object to the front of the internal LRU list to make sure it is removed last. The parameter handle is returned when called add().
1.8.12