FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

updated example · walker2010cs/cpp-taskflow@590bc1e · GitHub

Repository navigation

Commit 590bc1e

Browse files
updated example
1 parent e24e076 commit 590bc1e

4 files changed

Lines changed: 21 additions & 17 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int main(){
106106
B.precede(D); // B runs before D // | +---+ |
107107
C.precede(D); // C runs before D // +---->| C |-----+
108108
// +---+
109-
executor.run(taskflow);
109+
executor.run(taskflow).get();
110110

111111
return 0;
112112
}

‎example/parallel_for.cpp‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1+
// This program demonstrates how to use cpp-taskflow to
2+
// write loop-based parallelism.
3+
14
#include <taskflow/taskflow.hpp>
25
#include <cassert>
36
#include <numeric>
47

58
// Procedure: parallel_for_on_range
69
void parallel_for_on_range(int N) {
710

11+
tf::Executor executor;
12+
tf::Taskflow taskflow;
13+
814
std::vector<int> range(N);
915
std::iota(range.begin(), range.end(), 0);
1016

11-
tf::Taskflow tf;
12-
tf.parallel_for(range.begin(), range.end(), [&] (const int i) {
17+
taskflow.parallel_for(range.begin(), range.end(), [&] (const int i) {
1318
printf("parallel_for on container item: %d\n", i);
1419
});
15-
tf::Executor().run(tf);
20+
21+
executor.run(taskflow).get();
1622
}
1723

1824
// Procedure: parallel_for_on_index
1925
void parallel_for_on_index(int N) {
20-
tf::Taskflow tf;
26+
27+
tf::Executor executor;
28+
tf::Taskflow taskflow;
2129

2230
// [0, N) with step size 1
23-
tf.parallel_for(0, N, 1, [] (int i) {
31+
taskflow.parallel_for(0, N, 1, [] (int i) {
2432
printf("parallel_for on index: %d\n", i);
2533
});
26-
tf::Executor().run(tf);
34+
35+
executor.run(taskflow).get();
2736
}
2837

2938
// ----------------------------------------------------------------------------

‎example/run_variants.cpp‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
// 2019/05/14 - modified by Tsung-Wei Huang
2-
// - isolated executor from taskflow
3-
//
4-
// 2019/02/15 - modified by Tsung-Wei Huang
5-
// - refactored the code
6-
//
7-
// 2019/01/17 - created by Chun-Xun
8-
// - added example of using the Framework
1+
// This example demonstrates how to use different methods to
2+
// run a taskflow object.
93

104
#include <taskflow/taskflow.hpp>
115

‎example/simple.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include <taskflow/taskflow.hpp> // the only include you need
77

88
int main(){
9-
9+
10+
tf::Executor executor;
1011
tf::Taskflow taskflow;
1112

1213
auto [A, B, C, D] = taskflow.emplace(
@@ -21,7 +22,7 @@ int main(){
2122
B.precede(D); // D runs after B // +---->| C |-----+
2223
C.precede(D); // D runs after C // +---+
2324

24-
tf::Executor().run(taskflow); // create an executor to run the taskflow
25+
executor.run(taskflow).get();
2526

2627
return 0;
2728
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL