Are any GUI libs going to make use of signals/slots?

Lutger lutger.blijdestijn at gmail.com
Sat Dec 9 19:09:53 PST 2006


clayasaurus Wrote:

> Craig Black wrote:
> > Is anybody using or planning to use the new signal/slot feature?  Seems like
> > a powerful feature to me.  I'm curious as to its percieved utility to GUI
> > library maintainers.
> > 
> > -Craig 
> > 
> 
> I made a simple OpenGL based GUI for my little library that uses 
> signal/slots (note I just recently completed it but haven't used it for 
> any apps yet, except for test apps).
> 
> It makes it really easy for users to hook up their own custom code to 
> handle things such as buttons being clicked.
> 
> One thing I'm curious about is the efficiency of signals and slots. I'm 
> guessing it has slightly more overhead than a normal function call, 
> therefore it is not something to be calling constantly.
> 
> ~ Clay

Only way to be sure is to profile, but performance cost should be very small.  It is implemented like this, slot is the delegate:

foreach (slot; slots[0 .. slots_idx])
    if (slot)
        slot(i);

I think usage of signals will only matter if your code would benefit a lot  from being inlined, but better not to do assumptions. 





More information about the Digitalmars-d-dwt mailing list