Search code examples
c++concurrencygo

C++ libraries that implement Go goroutines or Go channels?


I'm working with a medium-sized C++ code base which is currently entirely single-threaded. The time has come, however, to pursue concurrency and parallelism for performance gains. I'm very interested in the concurrency model of Google's Go programming language, with very lightweight goroutines and a system of communicating channels.

Sadly, for a variety of perfectly valid reasons, the project needs to stay in C++. So my question is: Is there a C++ library that approximates the Go paradigm for parallelism? Specifically, is there an approximation of goroutines or go channels available for C++? My fallback plan is just to use boost::thread.

The application in question is a long-running proprietary simulation for the financial forecasting domain. It's usually CPU bound, but also gets blocked on IO when new data become available. Many of the computations involved are not dependent on previous results and could be fairly easily made to run in parallel. Being able to run the application in a distributed context is a long-term goal, but not one that needs to be solved immediately.


Solution

  • If your aim is primarily speeding up compute things, Intel's TBB (Threading Building Blocks) is (IMHO) a better option than rolling your own inferior version from boost::thread.