views:

315

answers:

7

What multi-threaded C++ library can be used for writing Linux, Windows, Solaris, and iPhone applications? Such as:

Any others?

A: 

qt has multi-threading support ...

Goz
It does, but it is not as standalone as I would like.
Dave Jarvis
A: 

You could use pthreads and implement your own C++ wrappers. That would be very flexible and portable, and you get to define the C++ interface the way that suits you. It is perhaps more effort on your part that you were intending however.

Clifford
+4  A: 

Boost threads is really the de facto C++ threading standard. I'd recommend at least familiarizing yourself with the Boost threading API, as it is more or less identical to the upcoming standardized C++0x std::thread.

Charles Salvia
Boost boosters (booboos?) may affect to believe this, but the defacto standard in as much as one exists is probably pthreads. But most people writing MT code find it hard to resist the allure of platform specific features. Or at least, I do.
anon
@Neil - that's a nice way of saying that boost/c++0x threads are plain vanilla.
Duck
@Neil - I agree that their is probably more pthread code around than boost. But given that std::thread will soon be the real standard (not de facto) and it is C++ (not C), I would say that any code written using boost threads will be more easily portable to std::thread when it is more widely available.
Nic Strong
@Nic - I suspect std::thread will be used when convenient or required but far from exclusively. Fopen() and family are standard C but many people opt to use the native system calls. I'm guessing the native_handle() call will be quite common.
Duck
A: 

For Part Two of your question:

Integrating C++ into Objective-C is extremely easy; I added a C++ library to my app with no trouble. You don't use any special syntax or anything. Apple has some good info on Objective-C++, but you have to already know Objective-C to understand it.

Caveat: To make an iPhone app, you have to know basic Objective-C; it's the only way to control the interface, at the least.

Chris Long
A: 

FWIW, I don't think all of these are completely equivalent.

ACE, Boost, Poco, and QT are just wrappers around the underlying supported threading platforms. OpenMP and especially TBB operate, to my mind, at a higher abstraction level and encourage a different way of looking at problems.

Duck
A: 

Boost.Thread is great.. but not sure if it will work on the iPhone. If you are targetting the iPhone, you should just use the NSThread class, in particular its detatchNewThreadSelector function in order to spawn a new thread. You can use the performSelectorOnMainThread function to perform work in the UI event thread.

The problem with using C++ on the iPhone is that the iPhone currently does not support C++ exceptions (it supports "SJLJ" exceptions that are used by Objective-C, but not standard C++ exceptions), which means that any C++ code that makes use of C++ exception handling will fail to link on the iPhone.

Michael Aaron Safyan
A quick Google showed some people were able to compile Boost's threading library for the iPhone.
Dave Jarvis
+1  A: 

I would also add POCO, which has been recently ported to the iPhone:

http://pocoproject.org/blog/?p=208

Adrian Kosmaczewski
Too difficult to create a static build. Also, it creates a directory that starts with a hyphen -- annoying.
Dave Jarvis