Functional-lang  0.0
An example functional programming language
Public Member Functions | List of all members
GCMain Class Reference

Implements a tracing garbage collector. More...

#include <gc.hpp>

Public Member Functions

bool getMarkBit () const noexcept
 
std::size_t getCountNewObjects () const noexcept
 
void add (GCObj *obj)
 Adds obj to all objects available. More...
 
void collect ()
 Collects garbage. More...
 

Detailed Description

Implements a tracing garbage collector.

Member Function Documentation

◆ add()

void GCMain::add ( GCObj *  obj)

Adds obj to all objects available.

Parameters
obj

◆ collect()

void GCMain::collect ( )

Collects garbage.

Use mark function of directly reachable objects (roots). Resets getCountNewObjects to 0.

◆ getCountNewObjects()

std::size_t GCMain::getCountNewObjects ( ) const
noexcept
Returns
Returns count of new objects since last collect call.
See also
collect

◆ getMarkBit()

bool GCMain::getMarkBit ( ) const
noexcept
Returns
Returns status of the mark bit.

This is a 'hack'. Otherwise the algorithm would be force to reset the mark bit after every collect. But if a the markbit can be toggled (its switched the mark state after collecting), it becomes obsolete.


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