Re: Handling referencing class parent instances in a GC friendly way.

2020-11-30 Thread realhet via Digitalmars-d-learn
On Monday, 30 November 2020 at 14:36:08 UTC, FeepingCreature wrote: On Monday, 30 November 2020 at 14:33:22 UTC, realhet wrote: ... Though you may want to do `items = null;` too. I just forgot 1 of three things, thx for pointing it out. And I also forget to notify the parent to remove the refer

Re: Handling referencing class parent instances in a GC friendly way.

2020-11-30 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 30 November 2020 at 14:33:22 UTC, realhet wrote: Hi, class A{ A parent; A[] items; void myDestroy(){ items.each!(i => i.myDestroy); parent = null; // after this point I think the GC will release it automatically, and it will call ~this() too. Am I right? } } I

Handling referencing class parent instances in a GC friendly way.

2020-11-30 Thread realhet via Digitalmars-d-learn
Hi, class A{ A parent; A[] items; void myDestroy(){ items.each!(i => i.myDestroy); parent = null; // after this point I think the GC will release it automatically, and it will call ~this() too. Am I right? } } I have a hierarchy of class instances forward and backward link