Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which light C++ event/delegate (signal/slot) library should I choose?

I know that the question has already been asked and answered, but it was more than one year ago and it looks like there are new alternatives out there.

So I'm coding a game with the SFML library (which I'm starting to find pretty much cool actually) and I'm looking for a light and fast event/delegate library.

After doing some research and having put aside the classical ones (Boosts.Signals, libsigc++), I found "cpp-events". It does not look very popular right now — since it is a very recent library — but it seems worst to be tested. I would be very interested to know if someone here tried it and can give a little feedback.

Do you have other similar (or better) options to suggest? I look rather real projects (which will be maintained) than answers on forums.

Thank you !

like image 318
Pym Avatar asked Mar 03 '10 01:03

Pym


2 Answers

My feeling is that http://www.codeproject.com/KB/cpp/ImpossiblyFastCppDelegate.aspx is a great implementation for games. No dynamic memory allocation, reasonable performance, simple to debug => great for games.

I have used similar delegates in the past, this implementation looks more efficient.

The one you suggested mentions thread safety, but I would not be comfortable with a delegate based interface being used between threads. That may work fine on a small project but if a team grows, so too does the potential for disaster. I would also question the performance implications of such a feature.

like image 193
Dan O Avatar answered Nov 02 '22 23:11

Dan O


Also take a look at Boost.Signals2 which is the thread-safe version of Boost.Signals. I'm using it at work in a medium-sized project and I'm quite happy with it.

like image 41
cairol Avatar answered Nov 02 '22 23:11

cairol