45
edits
Changes
→Asynchronous Multi-Threading
• packaged_task::get_future
However, a future object can only be used if it is in a valid state. Default future objects constructed from the std::async template function are not valid and must be assigned a valid state during execution.
Basic example of asynchronous multi-threading using std::async to create the thread and std::future to store the return result of their associated threads.
futures.push_back(std::async(twice, i));
}
for (int i = 0; i < futures.size(); i++){
std::cout << futures.at(i).get() << std::endl;
return 0;
}
===Programming Models===