Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/alloc/SimpleGC.h>
Public Member Functions | |
SimpleGC (t::size size=4096) | |
virtual | ~SimpleGC (void) |
void | clear (void) |
void | doGC (void) |
void * | allocate (t::size size) throw (BadAlloc) |
void | free (void *block) |
Protected Member Functions | |
bool | mark (void *data, t::size size) |
virtual void | beginGC (void) |
virtual void | collect (void)=0 |
virtual void | endGC (void) |
Basically, this allocator is a stack allocator that support monitored reference collection for garbage collection. This means that the user is responsible to provide the live references at garbage collection time. This is done by overloading the collect() method and calling mark() on each live block.
elm::SimpleGC::SimpleGC | ( | t::size | size = 4096 | ) |
Initialize the allocator.
size | Size of chunks. |
|
virtual |
Perform an allocation of the given size.
size | Size of allocated memory. |
|
protectedvirtual |
Called before a GC starts. Overriding methods must call this one.
References elm::stree::SegmentBuilder< K, T, C >::add(), and elm::stree::SegmentBuilder< K, T, C >::make().
Referenced by doGC().
void elm::SimpleGC::clear | ( | void | ) |
Reset the allocator.
|
protectedpure virtual |
|
protectedvirtual |
Referenced by doGC().
void elm::SimpleGC::free | ( | void * | block | ) |
|
protected |
Called to mark a block as alive.
data | Alive data block base. |
size | Size of block. |
References elm::_, elm::stree::Tree< K, T, C >::get(), and elm::io::hex().