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.

Reply via email to