We don’t allow q开发者_JAVA百科uestions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this questionWhat multi-threaded C++ library can be used for writing Linux, Windows, Solaris, and iPhone applications? Such as:
- TBB
- Boost
- OpenMP
- ACE
- POCO
Any others?
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
.
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.
I would also add POCO, which has been recently ported to the iPhone:
http://pocoproject.org/blog/?p=208
qt has multi-threading support ...
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.
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.
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.
精彩评论