Threads not garbage collected ?

Guillaume Piolat via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 23 01:46:11 PST 2017


On Wednesday, 22 February 2017 at 11:29:27 UTC, Alex wrote:
> The point is that the thread object could be 20 layers of 
> encapsulation down in a library.
> The thread could also be added 20 layers down long after the 
> main function was written and tested.
>

Here is what works for me:
- having a clear owner for things that may own resource 
transitively,
    => an acyclic graph of objects
- use destructors, _but ensure they are called manually not by 
the GC_,
- in each destructor, call .destroy on every members that are 
classes (in the right order if it matters),
- call .destroy on the top-level object to exit

It was insane before I did that.


More information about the Digitalmars-d mailing list