D2 weak references

Jason House jason.james.house at gmail.com
Sat Apr 18 20:59:12 PDT 2009


Jason House wrote:

> Tango's GC (and therefore
> druntime's GC) has an explicit notification mechanism.

I guess I shouldn't have assumed that the features of tango became part of 
druntime.  I don't see any notification mechanism :(

The best design I've come up with is to make a helper class 
weakReferencable(T) that will add a finalizer to fix any outstanding weak 
references.  I'd then use a double linked list of structs as weak 
references.  As long as collections are are single threaded, it should be 
pretty easy to make work.  Introducing a new type besides just a weak 
reference seems like a bit of a hack.  I'm hoping others will have 
suggestions on how to do that better.




More information about the Digitalmars-d mailing list