Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
SimpleGC Class Referenceabstract

#include <elm/alloc/SimpleGC.h>

Public Member Functions

 SimpleGC (t::size size=4096)
 
virtual ~SimpleGC (void)
 
void clear (void)
 
void doGC (void)
 
voidallocate (t::size size)
 
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)
 

Detailed Description

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.

See also
Temp, TempPtr.

Constructor & Destructor Documentation

◆ SimpleGC()

SimpleGC ( t::size  size = 4096)

Initialize the allocator.

Parameters
sizeSize of chunks.

◆ ~SimpleGC()

~SimpleGC ( void  )
virtual

Member Function Documentation

◆ allocate()

void * allocate ( t::size  size)

Perform an allocation of the given size.

Parameters
sizeSize of allocated memory.

References SimpleGC::doGC().

◆ beginGC()

void beginGC ( void  )
protectedvirtual

Called before a GC starts. Overriding methods must call this one.

Referenced by SimpleGC::doGC().

◆ clear()

void clear ( void  )

Reset the allocator.

◆ collect()

void collect ( void  )
protectedpure virtual

This function is called when references for a garbage collection are needed. It must call the mark() with each alive reference.

This function must be override in each use site in order to provide alive references.

Referenced by SimpleGC::doGC().

◆ doGC()

◆ endGC()

void endGC ( void  )
protectedvirtual

Referenced by SimpleGC::doGC().

◆ free()

void free ( void block)
inline

◆ mark()

bool mark ( void data,
t::size  size 
)
protected

Called to mark a block as alive.

Parameters
dataAlive data block base.
sizeSize of block.
Returns
True if the block has already been marked, false else.
Warning
This function must only be called from the collect() context!

References elm::_, Tree< K, T, C >::get(), elm::io::hex(), and elm::io::p().


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