This class has not be completely tested.
Since a garbage collectable object is not reclaimed by the collector
whenever there exists a reference to it, using the class
RewriteCache
may create problems since objects are not reclaimed
if it is referenced by the cache. The template class GCRewriteCache
solves this problem by using weak pointers in its internal
implementation.
The template class GCRewriteCache<T>
expects T
to be
a class derived from GCObject
.
This class implements the following functions:
GCRewriteCache(); GCRewriteCache(int capacity); ~GCRewriteCache(); void clear(); // after rewriting void initialize(); // before rewriting void initialize(int capacity); // before rewriting/also set capacity int capacity() const; void set_state(T * t, int s); int get_state(T * t) const; void invalidate(T * t);
The usage of these functions are identical to that of class
RewriteCache
.