#include <GarbageCollector.h>
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. |
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.
GarbageCollector::GarbageCollector | ( | Cache * | cache, | |
unsigned | sleepInterval | |||
) |
Starts the Garbage Collecting immidiately.
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.
void GarbageCollector::addObservedSpace | ( | Space * | space | ) |
Adds space to the list, to be included in garbage collection.
space | pointer to space |
Definition at line 68 of file GarbageCollector.cpp.
void GarbageCollector::removeObservedSpace | ( | Space * | space | ) |
Excludes given space from being garbage collected.
space | pointer to space |
Definition at line 75 of file GarbageCollector.cpp.
void GarbageCollector::setInterval | ( | unsigned | interval | ) |
Adjusts the sleep interval.
Synchronized.
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.