Which C++ signals/slots library should I choose? [closed]

Solution 1:

First, try with boost::signal anyway. Don't assume it will not be fast enough until you try in your specific case that is your application

If it's not efficient enough, maybe something like FastDelegate will suit your needs? (i did'nt try it but heard it was a nice solution in some cases where boost::signal don't seem to suit).

Anyway, if in your application use the signal each frame, it may be worth to replace the signal system by something more simple, like a container that hold objects/functors that will be called each frame. Signal is more made to allow immediate "events" management than to make a loop cycle dynamic (allowing changing the functions called each frame). (I have my own solution (UPDATE: it's very old and archaic now) that i heavily use in a game and for instance i've no problem with the performance, so maybe something similar could help).

Solution 2:

Very, very fast event library on Gamedev.net forms

When profiling some code I'd been working on recently, I was surprised and dismayed to see boost::signals functions floating to the top. For those of you who are unaware, boost::signals is a wonderfully useful signal/slot library which can be used alongside boost::bind for delegate-based event handling such as one sees in C#. It is robust, featureful, and flexible. It is also, I have learned, incredibly, terrifyingly slow. For a lot of people who use boost::signals this is fine because they call events very seldom. I was calling several events per frame per object, with predictable results.

So I wrote my own. Slightly less flexible and featureful. It's optimized for how everyone tends to actually use events. And event invocation is fifteen to eighty times faster than boost::signals.

see link

Solution 3:

The two you listed are the only two worth while that I'm aware of. Everything that I have seen has shown libsigc++ coming out on top performance wise. As you saw in the comparison, there are some instances where boost's syntax is a little prettier, but just a bit.

I've personally used libsigc++ and am happy with it. Libsigc++ seems to be used by vastly more projects. A quick look in my package manager lists more than 100 projects dependant on libsigc++2. That alone is enough in my opinion to tilt the balance especially considering the performance advantage and the lack of other significant differences.

I say libsigc++2.