The guys over at LMAX spent a lot of time looking at multithreaded software performance. Since computer performance will scale out with more processing cores rather than higher speeds for the foreseeable future, this seems like a good investment.
What they found is that the traditional methods of multi-threaded communication — namely, blocking queues — are really not the best way to send data between threads. They’ve done a pretty good job of writing up the details at http://code.google.com/p/disruptor/.
However, they’ve done all their work in Java. To be fair, that is where most high performance code is being written nowadays, particularly in finance. However, there’s no way for a C++ program to benefit from this work.
Consequently, I ported the LMAX Disruptor to C++, and released the source under the Apache 2 license. I started a Google Code page at http://code.google.com/p/disruptor-cpp/ to make it easily accessible.
The implementation wasn’t as straightforward as I would have thought — many features the Disruptor depends on (like atomic variables) wont be standard until C++0x is widely supported by compilers. In the meantime, I found that Boost provides a good stopgap set of features, and the implementation would have been orders of magnitude more complicated without it*.
As it is, I think the C++ interface is fairly comparable to the Java one. While the Disruptor is not as trivial to use as a blocking queue, the performance gains should be more than worth the extra coding effort. And I think the C++ interface is just a tad easier to work with than the Java version.
Check out the project at http://code.google.com/p/disruptor-cpp/ to get started. Code patches welcome!
* So if you’re one of those people who refuses to use Boost for some reason, tough nuggies.