ObjCache Class Reference

Cache for objects. More...

#include <objcache.h>

List of all members.

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 ()

Classes

struct  CacheNode
struct  HashNode


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.

Definition at line 33 of file objcache.h.


Constructor & Destructor Documentation

ObjCache::ObjCache ( unsigned int  logSize  ) 

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

Definition at line 32 of file objcache.cpp.

ObjCache::~ObjCache (  ) 

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

Definition at line 47 of file objcache.cpp.


Member Function Documentation

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.

Definition at line 53 of file objcache.cpp.

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().

Definition at line 72 of file objcache.h.

void ObjCache::del ( int  handle  ) 

Removes the item identified by handle from the cache.

See also:
add()

Definition at line 109 of file objcache.cpp.

Referenced by MemberDef::~MemberDef().

void ObjCache::printLRU (  ) 

Debug function. Prints the LRU list

void ObjCache::printStats (  ) 

Print miss/hits statistics

Definition at line 152 of file objcache.cpp.

References cache_stats_printf.


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



Generated on Mon Mar 31 10:59:02 2008 by  doxygen 1.5.1