Portable C++ multithreading

c++, multithreading, portability

Solution

Your best bet by far is to use the new std::threads library, this is portable and standardised and written in a modern style.

 std::thread my_thread(my_func, my_param);

http://en.cppreference.com/w/cpp/thread

If you don't have access to C++11 (VC10 and >gcc 4.4 should be fine), then the std::threads are more or less a developement of the great boost::threads, the boost library is cross platform and portable (at least it will support major OS include Win32 & linux).

http://www.boost.org/doc/libs/1_49_0/doc/html/thread.html

Finally if you are looking for parallelising algorithms it might be worth your while checking out intel's TBB, that is a modern C++ thread library that provides parallel constructs similar to the std:: algorithms

tbb::for_each(my_contaier.begin(), my_container.end(), my_func);

http://threadingbuildingblocks.org/

Problem

I'm writing a library in C++ language that uses multithreading. Since I'm developing it in windows, I'm using the method and the data structures in "Windows.h" (like `CreateThread`, `HANDLE WINAPI`, etc). Now I would like to make this code executable both in Windows and in Linux; can you suggest to me some threading implementations to do that? The main requirement of this application is execution speed, so I need some implementation that is fast. Thank in advance.

Original source

Related problems