www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17563] New: gc_inFinalizer should be public


          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: nobody puremagic.com
          Reporter: schveiguy yahoo.com

Currently there's a function gc_inFinalizer here:

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

Jun 27 2017