Am 14.04.2013 19:07, schrieb Robert: >> Does it mean you disagree with proposed compiler changes and with the >> idea we have to create weak reference functionality instead of >> recreating it every time it is needed (beside of theoretical danger such >> approach already showed it as a bad thing with `std.stdio.File` as I wrote)? >> > > > A weak reference could actually be implemented in the library relatively > easy. ( I basically did it for std.signals2 )
My memories tell me that I was never able to make a _thread safe_ weak reference, though. I don't remember exactly, but I think that it was because the dispose event happens after all threads have already restarted. This means that some thread could extract a strong reference from the weak reference before the weak reference knows that the underlying object has been destroyed, thus creating a dangling pointer.