Clean way to tell whether a destructor is called by the GC

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 12 05:31:33 PDT 2015


Let me suggest a completely different option: make a destructor 
that works while the GC is running by managing the resources 
manually in both construction and destruction. Remember, it isn't 
*all* reference types that are problematic to access, it is just 
GC managed references. So anything from a C function is cool.

Otherwise, accessing the runtime variable seems ok to me like the 
link said, hacky sure, but it'd work.... nothing else comes to 
mind, other than using a separate dispose() method when you 
delete it manually and leave the dtor for only the GC.


More information about the Digitalmars-d-learn mailing list