开发者

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

开发者 https://www.devze.com 2022-12-21 14:55 出处:网络
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.

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) 开发者_如何学JAVAoptions to suggest? I look rather real projects (which will be maintained) than answers on forums.

Thank you !


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消