D2 weak references
Daniel Keep
daniel.keep.lists at gmail.com
Sun Apr 19 19:50:09 PDT 2009
Sean Kelly wrote:
> Jason House wrote:
>> 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 :(
>
> Same as Tango:
>
> alias void delegate(Object) DEvent;
> extern (C) void rt_attachDisposeEvent(Object h, DEvent e);
> extern (C) void rt_detachDisposeEvent(Object h, DEvent e);
>
> I should probably expose these in core.runtime.
How are these events dispatched? I remember a discussion about race
conditions if these events were fired off after all threads had been
resumed; you could have the event zero out the weak ref AFTER something
else had dereferenced it.
If that's still a possibility, maybe you could add a case where if the
delegate's funcptr is null, it just assumes the context pointer points
to a void*.sizeof word and zeroes it out. You could do that without
resuming threads.
-- Daniel
More information about the Digitalmars-d
mailing list