Since my last post on a fast thread-safe Signals/Slots implementation I've had to do a major re-write. The problem was that I had merged "slots" with nodes. This made implementing "self-disconnecting" slots near impossible (or at least, very inefficient). I also had structured my code quite poorly so managing includes was a nightmare.
Getting the Code
The code is currently being hosted by GitHub. It is released under the Boost Software License, v1.0. For those who pay attention to the commit dates, they'll realize that the repo is actually newer than some of my posts on the subject (yes, I wrote those posts in advance). At this time I have implemented nearly all features offered by Boost Signals2, though there may be bugs in the code. See the repository for up-to-date and more specific information on the state of the project .
These results were tested using this revision. I've listed performance stats for using the library in both thread-safe and thread-unsafe mode. As always, I'm building with Mingw-w64* for x64 Windows 7 (gcc 4.8.1), running on a laptop with an Intel i5-m430.
|Test Case||No Slots (ns)||1 Slot (ns)||2 Slots (ns)||4 Slots (ns)||8 Slots (ns)||16 Slots (ns)||32 Slots (ns)||64 Slots (ns)||static overhead (ns)||dynamic overhead (ns/slot)|
|Signals3 Thread-safe mode||17||52||86||153||290||559||1098||2158||17||33|
|Signals3 Thread-unsafe mode||17||44||69||123||227||435||842||1650||17||25|
Implementing the automatic disconnect feature has slightly reduced the performance of the library, but it is still quite fast compared to other thread-safe implementations. I don't expect emit performance to change as I add on the last few missing features because none of them require modifying the emit algorithm. The implementation has reached at least a "playable" state, but is still far from being production-ready due to the lack of extensive testing. Comments and suggestions for improvement are definitely welcome.