anAppBuilder
asked on
gcc std::thread vs boost::thread
I want to add threads to a multi-platform C++ application. I've been using gcc with mingw on Win 7 and want to upgrade to mingw-w64. When I start the install of mingw-w64 it asks whether I want POSIX or Windows threads.
Does this mean there is no "standard" thread in C++2011?
Other sites imply that POSIX thread is an emulation on Windows and raise questions about it's reliability. Is selecting POSIX threads on Windows a viable option?
Would it be safer for now to use boost::thread and wait for C++2014 to implement really standard threading?
Does this mean there is no "standard" thread in C++2011?
Other sites imply that POSIX thread is an emulation on Windows and raise questions about it's reliability. Is selecting POSIX threads on Windows a viable option?
Would it be safer for now to use boost::thread and wait for C++2014 to implement really standard threading?
ASKER
Thank you, jkr.
The problem is the mingw offers me p-threads or Windows threads. There is no option for C++11 threads which is what I want.
Am I using the wrong tools? Is there some other platform independent compiler I should be using?
The problem is the mingw offers me p-threads or Windows threads. There is no option for C++11 threads which is what I want.
Am I using the wrong tools? Is there some other platform independent compiler I should be using?
What version of MinGW are we talking about? 4.7.2 or higher do support these features..
ASKER
I went to this page GCC for both 64 & 32 bits Windows.
I selected this download: Mingw-builds project - native toolchains using trunk.
Should I select this one? Win-builds project - stable, native- and cross- compilers plus libraries and a cross-platform package manager
I selected this download: Mingw-builds project - native toolchains using trunk.
Should I select this one? Win-builds project - stable, native- and cross- compilers plus libraries and a cross-platform package manager
ASKER
In the former case, I selected gcc 4.8.3.
In the latter case the only choice would be gcc 4.8.2
In the latter case the only choice would be gcc 4.8.2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, jkr. It's taking me a while to get the new environment set up, so I can't yet tell you what is working (or not).
ASKER
Thank you, jkr. I selected POSIX and it works fine.
No, there for sure ins 'std::thread', see http://en.cppreference.com/w/cpp/thread/thread
>> Is selecting POSIX threads on Windows a viable option?
The both the POSIX and the C++11 encapsulation for threads (plus boost's) will end up using Windows APIs for threading anyway, and so will any other library.
From a multi-platform POV, I'd definitely go for either boost or C++11 (well, both being almost the same now), and if you plan to use C++11 features anyway, strike out pthreads from your considerations. If you however require backwards compatibility and no C++11 features, both boost and pthreads should remain considered.