ISLEman
Classes | Public Member Functions | List of all members
ObjCache Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

§ ObjCache()

ObjCache::ObjCache ( unsigned int  logSize)

Creates the cache. The number of elements in the cache is 2 to the power of logSize.

§ ~ObjCache()

ObjCache::~ObjCache ( )

Deletes the cache and free all internal data-structures used.

Member Function Documentation

§ add()

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.

§ count()

int ObjCache::count ( ) const
inline

number of elements in the cache

§ del()

void ObjCache::del ( int  handle)

Removes the item identified by handle from the cache.

See also
add()

§ printLRU()

void ObjCache::printLRU ( )

Debug function. Prints the LRU list

§ printStats()

void ObjCache::printStats ( )

Print miss/hits statistics

§ size()

int ObjCache::size ( ) const
inline

total size of the cache

§ use()

void ObjCache::use ( int  handle)
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().


The documentation for this class was generated from the following files: