44 auto global_thread_func = std::async(
global_sum, 2, 3);
60 auto functor_thread_func = std::async(
SquareSum{}, 5);
63 auto lambda_thread_func = std::async([](
int a,
int b,
int c)
64 {
return a*a + b*b + c*c; }, 1, 2, 3);
68 stream <<
"global_thread_func - sum of 2, 3: " << global_thread_func.get() <<
tpf::endl;
69 stream <<
"member_square_sum_fun - square_sum of 3, 4: " << member_square_sum_fun.get() <<
tpf::endl;
70 stream <<
"static_member_function - sum_square of 3, 4: " << static_member_function.get() <<
tpf::endl;
71 stream <<
"functor_thread_func - square sum of 5: " << functor_thread_func.get() <<
tpf::endl;
72 stream <<
"lambda_thread_func - sum of squares if 1, 2, 3 :" << lambda_thread_func.get() <<
tpf::endl;
74 catch(
const std::exception& e)
93 auto global_thread_func = std::async(std::launch::async,
global_sum, 2, 3);
109 auto functor_thread_func = std::async(std::launch::async,
SquareSum{}, 5);
112 auto lambda_thread_func = std::async(std::launch::async, [](
int a,
int b,
int c)
113 {
return a*a + b*b + c*c; }, 1, 2, 3);
117 stream <<
"global_thread_func - sum of 2, 3: " << global_thread_func.get() <<
tpf::endl;
118 stream <<
"member_square_sum_fun - square_sum of 3, 4: " << member_square_sum_fun.get() <<
tpf::endl;
119 stream <<
"static_member_function - sum_square of 3, 4: " << static_member_function.get() <<
tpf::endl;
120 stream <<
"functor_thread_func - square sum of 5: " << functor_thread_func.get() <<
tpf::endl;
121 stream <<
"lambda_thread_func - sum of squares if 1, 2, 3 :" << lambda_thread_func.get() <<
tpf::endl;
123 catch(
const std::exception& e)
void example_for_thread_functions_async()
void example_for_thread_functions()
int global_sum(int a, int b)
int operator()(int n) const
static int sum_square(int a, int b)
int square_sum(int a, int b)
Stream output operators << are implemented.