Introduction
Before C++11, C++ didn't have much support for parallelization. This does not mean that starting, controlling, stopping, and synchronizing threads was not possible, but it was necessary to use operating system-specific libraries because threads are inherently operating system-related.
With C++11, we got std::thread
, which enables basic portable thread control across all operating systems. For synchronizing threads, C++11 also introduced mutex classes and comfortable RAII-style lock wrappers. In addition to that, std::condition_variable
allows for flexible event notification between threads.
Some other really interesting additions are std::async
and std::future
--we can now wrap arbitrary normal functions into std::async
calls in order to execute them asynchronously in the background. Such wrapped functions return std::future
objects that promise to contain the result of the function later, so we can do something else before we wait for its arrival.
Another actually enormous improvement...