Performance of boost::signals2
I'm switching from xlobjects to boost::signals2 as my signal/slot framework in the hope that the establishment of connections, threir removal, signal emission, etc is thread-safe. I'm not interested in inter-thread signal emission at all.
So the simple question is: is boost::signals2 thread safe in the way that, for instance, 开发者_C百科two or more threads can make a connection on the same signal?
Also, does boost::signals2 incur a performance penalty compared to xlobjects? This is not important as the application doesn't rely heavily on signals/slots, but I'd like to know nevertheless.
boost signals2 is thread safe.
but if for some reason you need extra performance, and can guarantee the single thread access, there is a dummy mutex in the signals2 library that will be a lot faster than a real mutex.
I believe all the answers you need regarding thread safety in boost.signal are in the documentation (short answer : yes, boost:signals2 is thread safe). Regarding performance, I guess thread-safety comes at a cost, but there's only one way to be sure : benchmark !
精彩评论