DIP18: Non-GC threads

Michel Fortin michel.fortin at michelf.ca
Fri Aug 31 20:20:36 PDT 2012


> If some of the function's arguments take references (directly or 
> indirectly), then all of them are automatically added to the list of GC 
> roots (addRoot()).

You still have a problem: you might have added an object passed as an 
argument to the GC roots, preventing the GC from collecting it, but if 
any thread is allowed to mutate a pointer inside this object pointing 
to some other data, using this other data in your thread is not safe, 
unless you have added a root for this other pointer too. You'd have to 
recursively add roots for this to work.

There's also the same issue with global variables, the ones which are 
pointers to other pointers.

-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca/



More information about the Digitalmars-d mailing list