GarbageCollector Class Reference

A background cache cleaner. More...

#include <GarbageCollector.h>

List of all members.

Public Member Functions

 GarbageCollector (Cache *cache, unsigned sleepInterval)
 Starts the Garbage Collecting immidiately.
virtual ~GarbageCollector ()
 Terminates the Garbage Collector's thread.
void addObservedSpace (Space *space)
 Adds space to the list, to be included in garbage collection.
void removeObservedSpace (Space *space)
 Excludes given space from being garbage collected.
void setInterval (unsigned interval)
 Adjusts the sleep interval.
void operator() ()
 A main method of GC thread.


Detailed Description

A background cache cleaner.

Garbage Collector scans registered spaces for entries that are expired and removes them from memory. After that it also checks whether the hard quota is exceeded or not. If so it removes the valid (not expired) entries from the cache in the LRU order until the hard quota is exceeded. Garbage Collector acts un-aggressively - it has lower priority that SETs and GETs.

Definition at line 27 of file GarbageCollector.h.


Constructor & Destructor Documentation

GarbageCollector::GarbageCollector ( Cache cache,
unsigned  sleepInterval 
)

Starts the Garbage Collecting immidiately.

Parameters:
cache pointer to cache
sleepInterval GC after scanning registered spaces sleeps for sleepInterval miliseconds

Definition at line 37 of file GarbageCollector.cpp.

GarbageCollector::~GarbageCollector (  )  [virtual]

Terminates the Garbage Collector's thread.

It waits until the currently checked space is scanned.

Definition at line 57 of file GarbageCollector.cpp.


Member Function Documentation

void GarbageCollector::addObservedSpace ( Space space  ) 

Adds space to the list, to be included in garbage collection.

Parameters:
space pointer to space

Definition at line 68 of file GarbageCollector.cpp.

void GarbageCollector::removeObservedSpace ( Space space  ) 

Excludes given space from being garbage collected.

Parameters:
space pointer to space

Definition at line 75 of file GarbageCollector.cpp.

void GarbageCollector::setInterval ( unsigned  interval  ) 

Adjusts the sleep interval.

Synchronized.

Parameters:
interval GC after scanning registered spaces sleeps for sleepInterval miliseconds

Definition at line 91 of file GarbageCollector.cpp.

void GarbageCollector::operator() (  ) 

A main method of GC thread.

Method invoked by thread. It runs the garbage collection algorithm.

Definition at line 99 of file GarbageCollector.cpp.


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

Generated on Fri Jan 8 10:38:13 2010 for dreamcache by  doxygen 1.5.5