std.signals2 proposal

eskimo jfanatiker at gmx.at
Tue Nov 6 14:35:58 PST 2012


Completely working version online, all unit tests pass:

https://github.com/eskimor/phobos/blob/new_signal/std/signals.d


Although I will add some more, especially for the new functionality.

I don't expect signals in D being as overused as in Qt (because we have
delegates which are often the better choice), but nevertheless very
often signals will be declared for a class but not used for many
objects, so I think it is important to reduce the memory requirements of
an empty signal to a bare minimum.

I intent to do this by using a single array for both the delegates and
the object pointers, this will also simplify the implementation. For
this to work I would put everything in a standard D array (no malloc)
and will simply invert the object pointer so it won't keep the object in
memory on garbage collection. This could also save us the slot_idx
variable, by using assumeSafeAppend. 

I don't think that using malloc for this single array will buy me
anything, because I would have to add elements of the array to the gc
roots, which can't really be more efficient in any way.



More information about the Digitalmars-d mailing list