3

I am familiar with concurrent programming in Java which provides a lot of tools for this. However, C++ concurrent programming isn't so easy to start using.

What is the best way to start programming concurrently on C++? Are there any nice libraries which wrap concurrent programming primitives and provide you with more high-level constructs?

I tried QtConcurrent which provides you with nice MapReduce functionality but it is heavily biased towards concurrent computation using Qt so it's not a good choice if you don't want to use Qt.

Are there any other similar libraries? What do people use here?

Thanks for your help in advance, sneg

sneg
  • 2,088
  • 4
  • 19
  • 23

5 Answers5

11

There are several choices:

ACE which provides some concurrency constructs

Intel Threading Building Blocks

boost::threads

OpenMP

Qt Threading libraries

feedc0de
  • 3,646
  • 8
  • 30
  • 55
Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137
4

Morendil's suggestion (CSP - communicating sequential processes) is truly interesting to take a look at - it's a very different view of threading and one that works well once you wrap your head around it. I first encountered it in the rather esoteric Occam language for Transputers, but the idea has stuck with me.

A more conventional idea: boost::threads work quite well for building thread-based concurrent programs. It's quite low level though.

OpenMP is at a higher level than threads and also quite well-supported.

Joris Timmermans
  • 10,814
  • 2
  • 49
  • 75
  • Yes, you're right - with OpenMP the developer doesn't have to worry about actual threads. It's a parallelism library rather than a threading library. – Joris Timmermans Feb 20 '09 at 13:38
3

You could look at CSP, which has a C++ implementation. Way different from Java's threading primitives, though.

Morendil
  • 3,918
  • 20
  • 22
2

This question along with the answers can probably help you a little bit.

Community
  • 1
  • 1
Anonymous
  • 18,162
  • 2
  • 41
  • 64
1

Intel's Threading Building Blocks is great for introducing concurrency at the level of individual data-parallel loops, and it takes care of managing threads and allocating work automagically. It can be used in similar ways to OpenMP, but without the need for explicit compiler support.

Simon C.
  • 273
  • 1
  • 5