https://issues.dlang.org/show_bug.cgi?id=17563
Issue ID: 17563
Summary: gc_inFinalizer should be public
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
Currently there's a function gc_inFinalizer here:
https://github.com/dlang/druntime/blob/master/src/core/memory.d#L150
This function allows one to tell inside a destructor whether the GC finalizer
is running or not. This is currently the only way a destructor can tell whether
it's in the GC finalizer stage or not (you should only access GC members if not
inside the finalizer).
A crude and horrible way to check for this is to try allocating inside the
destructor, and catching the Error (an Error is thrown if inFinalizer is true).
There's no reason we shouldn't just allow others to call this (they technically
can already since it's extern(C)). It should be made part of the core.memory
interface.
--