Pagini recente » Monitorul de evaluare | Diferente pentru training-path intre reviziile 114 si 113 | Borderou de evaluare (job #2244981) | Monitorul de evaluare | Cod sursa (job #2159889)
#include <ctime>
#include <future>
#include <thread>
#include <iostream>
int long_computation(int x, int y)
{
std::this_thread::sleep_for(std::chrono::seconds(5));
return (x + y);
}
int main()
{
auto f = std::async(std::launch::async, long_computation, 42, 1729);
// Do things in the meanwhile...
std::string s;
std::cin >> s;
// And we could continue...
std::cout << f.get(); // Here we join with the asynchronous operation
}