C++17 in details: Parallel Algorithms

Writing multithreaded code is hard. You want to utilize all of the machine’s processing power, keep code simple and avoid data races at the same time. Let’s see how C++17 can make writing parallel code a bit easier. Intro With C++11⁄14 we’ve finally got threading into the standard library. You can now create std::thread and not just depend on third party libraries or a system API.

READ MORE...

Tasks with std::future and std::async

Let us consider a simple task: “Use a worker thread to compute a value”. In the source code it can look like that: std::thread t([]() { auto res = perform_long_computation(); }; Now, you would like to obtain the result when the computation is completed. How to do it efficiently?

READ MORE...