-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPplExample1.cpp
More file actions
49 lines (37 loc) · 1012 Bytes
/
Copy pathPplExample1.cpp
File metadata and controls
49 lines (37 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2013 John R. Bandela
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#define PPL_HELPER_OUTPUT_ENTER_EXIT
#include <ppltasks.h>
#include <iostream>
#include <string>
#include "ppl_helper.hpp"
int main(){
concurrency::task<int> t ([]()->int{
return 5;
});
auto t3 = ppl_helper::do_async([t](ppl_helper::async_helper<int> helper)->int{
auto sum = 0;
for(int i = 0; i < 5; ++i){
sum+= helper.await(t);
}
return sum;
});
auto t4 = ppl_helper::do_async([t,t3](ppl_helper::async_helper<int> helper)->int{
auto sum = 0;
for(int i = 0; i < 5; ++i){
sum+= helper.await(t3);
}
return sum;
});
std::cerr << "Called do_async\n";
try{
std::cout << t4.get();
}
catch(std::exception& e){
std::cerr << e.what();
}
return 0;
}