September 2017
Beginner to intermediate
384 pages
8h 4m
English
In the previous section, you learned how packaged_task can be used in an elegant way. I love lambda functions a lot. They look a lot like mathematics. But not everyone likes lambda functions as they degrade readability to some extent. Hence, it isn't mandatory to use lambda functions with a concurrent task if you don't prefer lambdas. In this section, you'll understand how to use a concurrent task with the thread support library, as shown in the following code:
#include <iostream>#include <future>#include <thread>#include <functional>using namespace std;int add ( int firstInput, int secondInput ) { return firstInput + secondInput;}int main ( ) { packaged_task<int (int, int)> addTask( add); future<int> ...