实现Go goroutine或Go通道的C ++库?

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.

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.

This question and in a general a google search for "C++ coroutines" should get you something close. The SO question suggests trying Boost::coroutine.

If you don't mind wrapping C you might be able to try libtask. Which was written by Russ Cox (one of the official Go dev team) before work on Go began. I've only used it in C though, so I don't know if it's applicable.

Go channels are implemented as locking queues by the way, so you might be able to incorporate a similar mechanism using regular threads.

Try GBL library, it has everything: coroutines (fibers), threads, sync and async handlers -- and it's all modern C++.

From what I have seen so far, cilk seems to be quite similar to go's style of parallelism. It looks like Intel has bought it and provides commercial support with Intel Cilk Plus.