Best callback technique
I have to agree that the system of using "signals" and "slots" via boost / Qt is the most efficient way of doing callbacks when I need them.
My favourite method is the interface based callback - its cheap and easy to implement. boost signal / slots are a more powerful alternative if you like to bind individual functions as the callback receivers instead of a whole class.
Boost Signal / Slots is a very good solution on all fronts, but it's speed might be lacking for you. For my specific tests, SigC++ was twice as fast (but measure this for your particular use!). I wrote my own limited kind of signal/slots, which is again 3 times faster, roughly.
So, check for yourself. Boost is truely not a fast solution for signals/slots, but it sure is stable, compatible, etc.
So, check for yourself. Boost is truely not a fast solution for signals/slots, but it sure is stable, compatible, etc.
Quote:Original post by Decrius
Boost Signal / Slots is a very good solution on all fronts, but it's speed might be lacking for you.
Quote:Original post by Anton Vatchenko
2. Good speed (if there is about thousand callbacks per frame).
I can't imagine a thousand callbacks per frame being a performance problem.
if you imagine about 200 frames per second, and this callback system is not the main target in application.
Quote:Original post by Anton Vatchenko
if you imagine about 200 frames per second, and this callback system is not the main target in application.
In a quick test on my computer, it looks like the overhead would take about 3% of the CPU under those circumstances. But such a simple synthetic test doesn't mean much, so you will have to do your own profiling.
We can't help you decide what to use: We can only point out alternatives for you to try. If you can budget boost::signals, they are a very elegant way to do things. An old-fashioned function pointer is much much faster, so I am sure there will be some speed/elegance compromise that you can use.
Quote:Original post by Anton Vatchenko
if you imagine about 200 frames per second, and this callback system is not the main target in application.
boost::function is fine then. It's ISO certified up to 220 (160 in Imperial units) frames per second.
Quote:Original post by AntheusQuote:Original post by Anton Vatchenko
if you imagine about 200 frames per second, and this callback system is not the main target in application.
boost::function is fine then. It's ISO certified up to 220 (160 in Imperial units) frames per second.
LOL!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement