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

#include <elm/alloc/AbstractGC.h>

+ Inheritance diagram for AbstractGC:

Public Member Functions

 AbstractGC (GCManager &m)
 
virtual ~AbstractGC ()
 
virtual voidallocate (t::size size)=0
 
virtual void free (void *block)
 
template<class T >
voidalloc ()
 
virtual void runGC ()=0
 
virtual bool mark (void *data, t::size size)=0
 
virtual void disable ()=0
 
virtual void enable ()=0
 
virtual void clean ()=0
 

Protected Attributes

GCManagermanager
 

Constructor & Destructor Documentation

◆ AbstractGC()

AbstractGC ( GCManager m)
inline

Build a garbage collector using the given manager.

Parameters
mManager of the garbage collector.

◆ ~AbstractGC()

~AbstractGC ( )
virtual

Member Function Documentation

◆ alloc()

void * alloc ( )
inline

Allocate the memory for an object of the given class. This function can be used this way:

MyClass *p = new(gc.alloc<MyClass>()) MyClass();
Parameters
TClass of the object to allocate.
Returns
Allocated object.

References AbstractGC::allocate().

◆ allocate()

void * allocate ( t::size  size)
pure virtual

Allocate a block of the given size. This function is often used this way:

MyClass *p = new(gc.allocate(sizeof(MyClass)) MyClass();
Parameters
sizeSize of the memory to allocate.
Returns
Allocated object.

Implemented in ListGC.

Referenced by AbstractGC::alloc().

◆ clean()

void clean ( )
pure virtual

Clean the memory allocated in the garbage collector and reset it to its initial state.

Implemented in ListGC.

◆ disable()

void disable ( )
pure virtual

Disable the automatic run of the garbage collection.

Implemented in ListGC.

◆ enable()

void enable ( )
pure virtual

Disable the automatic run of the garbage collection. May trigger immediately a GC cycle.

Implemented in ListGC.

◆ free()

void free ( void block)
virtual

Only kept for the compatibility with the memory interface. Does nothing.

Parameters
blockBlock to free.

◆ mark()

bool mark ( void data,
t::size  size 
)
pure virtual

Record the given block as alive. This function can only be called during a garbage collection cycle.

Parameters
dataPointer to the alive memory block.
sizeSize of the block.
Returns
True if the block has already been collected, false else.

Implemented in ListGC.

◆ runGC()

void runGC ( )
pure virtual

Called to start, by hand, a garbage collection cycle. Depending on the underlying implementation, this function may be automatically called by the garbage collector itself. Notice that during a garbage collection cycle, any call to allocate() or alloc() is forbidden.

Implemented in ListGC.

Member Data Documentation

◆ manager

GCManager& manager
protected

Referenced by ListGC::clean(), and ListGC::runGC().


The documentation for this class was generated from the following files:
elm::io::p
Printable< T, M > p(const T &data, const M &man)
Definition: Output.h:302
elm::AbstractGC::AbstractGC
AbstractGC(GCManager &m)
Definition: AbstractGC.h:40