Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

core.gc.registry

Contains a registry for GC factories.
Authors:
Martin Nowak
alias GCFactory = GC function();
A factory function that instantiates an implementation of the GC interface. In case the instance was allocated on the C heap, it is supposed to free itself upon calling it's destructor.
The factory should print an error and abort the program if it cannot successfully initialize the GC instance.
alias GCThreadInitFunction = void function(ThreadBase base) nothrow @nogc;
A function that will initialize a thread before the GC has been initialized. Once the GC is initialized, the interface method GC.initThread for each new thread.
nothrow @nogc void registerGCFactory(string name, GCFactory factory, GCThreadInitFunction threadInit = null);
Register a GC factory under the given name. This function must be called from a C constructor before druntime is initialized.
To use the registered GC, it's name must be specified gcopt runtime option, e.g. by passing , --DRT-gcopt=gc:my_gc_name as application argument.
The thread init function will be called only before the GC has been initialized to the registered GC. It is called as the first step in starting the new thread before the thread is registered with the runtime as a running thread. This allows any specific thread data that is needed for running the GC to be registered with the thread object.
After the GC is initialized, the GC interface function initThread is called instead. This function should expect the possibility that the reciprocal cleanupThread method may not be called if the GC is never initialized.
Parameters:
string name name of the GC implementation; should be unique
GCFactory factory function to instantiate the implementation
GCThreadInitFunction threadInit function to call from a new thread before registration in the list of running threads, to set up any GC-specific data.

Note The registry does not perform synchronization, as registration is assumed to be executed serially, as is the case for C constructors.

GC createGCInstance(string name);
Called during runtime initialization to initialize a GC instance of given name.
Parameters:
string name name of the GC to instantiate
Returns:
The created GC instance or null if no factory for that name was registered
nothrow @nogc GCThreadInitFunction threadInit(string name);
Get the thread init function used for the selected GC.
Note, this must be called before createGCInstance. It is typically called by rt_init.