On Friday, 29 November 2013 at 16:48:58 UTC, Temtaime wrote:
Hi !
http://dpaste.dzfl.pl/53d9a59e

How i can enforce that ~A will be called after ~B ?

I'm writing 3D engine and it's critical to me.

Thanks for yours aid !

It is impossible to do this directly given current gc implementation, but you can do something like that:

class A
{
   bool reset;
   void delegate dtor();
   ~this()
   {
      if (!reset)
         dtor();
   }
}

class B
{
   A a;
   bool run;
   ~this() { if (!run) a.reset = true; run = true; }
}

A a = new A;
B b = new B;
b.a = a;
b.a.dtor = & b.__dtor;

Reply via email to