22 std::packaged_task<int()> task([]() {
return 7; });
24 std::thread(std::move(task)).detach();
27 TFuture<int> f2 = std::async(std::launch::async, []() {
return 8; });
32 std::thread([&p] { p.set_value(9); }).detach();
34 std::cout <<
"Waiting..." << std::flush;
38 std::cout <<
"Done!\nResults are: " << f1.get() <<
' ' << f2.
get() <<
' ' << f3.get() <<
'\n';
A TFuture class. It can wrap an std::future.