Clean way to tell whether a destructor is called by the GC
ponce via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 12 05:12:14 PDT 2015
I need a robust "isCalledByGC" function to leak intentionally
when a destructor is called as a result of the GC.
It is a way to enforce deterministic destruction without ever
relying on accidental correctness.
class A
{
~this()
{
if(iscalledByGC())
{
[leak and write an error to stderr]
}
else
{
[normal release of resources]
}
}
}
Prior solution:
http://forum.dlang.org/post/li2oj4$1avo$1@digitalmars.com but
that involves modifying the runtime.
More information about the Digitalmars-d-learn
mailing list