signal slots (new, fixed version)

Sean Kelly sean at f4.ca
Wed Nov 1 15:48:34 PST 2006


Walter Bright wrote:
> J Duncan wrote:
>> You are the man! I have been experimenting with hooking into object 
>> destruction by replacing the dtor pointer in the classinfo.
> 
> I looked into that, too, and decided that it was never going to work. 
> Everything I thought of just cost too much memory and runtime for all 
> objects, not just hooked ones.

I agree.  Ares allows object destruction in general to be hooked, but 
it's really more for detecting memory 'leaks' (non-deterministic 
destruction) and for conditionally special handling of the destruction 
of certain object types.  While I haven't used the new hooking mechanism 
yet, it does seem to be the most appropriate solution for signals/slots.

>> I came across the monitor reference today in the ABI docs and have 
>> been looking into it - wondering what you are up to. This is Very 
>> Cool! Thanks!
> 
> I had a flash of inspiration one day that I was trying to hook in the 
> wrong place. Since the monitor is an opaque type, that could be hooked 
> with only a bit of casting, and it wouldn't affect anything else. Best 
> of all, it only costs if it is used, not for the usual case. The 
> monitors even still work with hooked objects.

Yup, this was definitely a nice way to do it.  And it came with a 
rewrite of the monitor code to boot :-)  I think the result is cleaner 
overall than what we had before.


Sean



More information about the Digitalmars-d-announce mailing list