Skip to content

Commit 3e863e1

Browse files
updated readme and simple.cpp
1 parent 93aa970 commit 3e863e1

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,28 @@ It is by far faster, more expressive, and easier for drop-in integration than ex
1515

1616
# Get Started with Cpp-Taskflow
1717

18-
The following example [simple.cpp](./example/simple.cpp) contains the basic syntax you need to use Cpp-Taskflow.
18+
The following example [simple.cpp](./example/simple.cpp) shows the basic API you need to use Cpp-Taskflow.
1919

2020
```cpp
21-
// TaskA---->TaskB---->TaskD
22-
// TaskA---->TaskC---->TaskD
23-
2421
#include "taskflow.hpp" // the only include you need
2522

2623
int main(){
2724

2825
tf::Taskflow tf(std::thread::hardware_concurrency());
2926

3027
auto [A, B, C, D] = tf.silent_emplace(
31-
[] () { std::cout << "TaskA\n"; },
32-
[] () { std::cout << "TaskB\n"; },
33-
[] () { std::cout << "TaskC\n"; },
34-
[] () { std::cout << "TaskD\n"; }
35-
);
36-
37-
A.precede(B); // B runs after A
38-
A.precede(C); // C runs after A
39-
B.precede(D); // D runs after B
40-
C.precede(D); // C runs after D
41-
42-
tf.wait_for_all(); // block until all tasks finish
28+
[] () { std::cout << "TaskA\n"; }, // the taskflow graph
29+
[] () { std::cout << "TaskB\n"; }, //
30+
[] () { std::cout << "TaskC\n"; }, // +---+
31+
[] () { std::cout << "TaskD\n"; } // +---->| B |-----+
32+
); // | +---+ |
33+
// +---+ +-v-+
34+
A.precede(B); // B runs after A // | A | | D |
35+
A.precede(C); // C runs after A // +---+ +-^-+
36+
B.precede(D); // D runs after B // | +---+ |
37+
C.precede(D); // C runs after D // +---->| C |-----+
38+
// +---+
39+
tf.wait_for_all(); // block until finished
4340

4441
return 0;
4542
}

example/simple.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@
33
// TaskA---->TaskB---->TaskD
44
// TaskA---->TaskC---->TaskD
55

6-
#include "taskflow.hpp"
6+
#include "taskflow.hpp" // the only include you need
77

88
int main(){
99

1010
tf::Taskflow tf(std::thread::hardware_concurrency());
1111

1212
auto [A, B, C, D] = tf.silent_emplace(
13-
[] () { std::cout << "TaskA\n"; },
14-
[] () { std::cout << "TaskB\n"; },
15-
[] () { std::cout << "TaskC\n"; },
16-
[] () { std::cout << "TaskD\n"; }
17-
);
18-
19-
A.precede(B); // B runs after A
20-
A.precede(C); // C runs after A
21-
B.precede(D); // D runs after B
22-
C.precede(D); // C runs after D
23-
24-
tf.wait_for_all(); // block until all task finish
13+
[] () { std::cout << "TaskA\n"; }, // the taskflow graph
14+
[] () { std::cout << "TaskB\n"; }, //
15+
[] () { std::cout << "TaskC\n"; }, // +---+
16+
[] () { std::cout << "TaskD\n"; } // +---->| B |-----+
17+
); // | +---+ |
18+
// +---+ +-v-+
19+
A.precede(B); // B runs after A // | A | | D |
20+
A.precede(C); // C runs after A // +---+ +-^-+
21+
B.precede(D); // D runs after B // | +---+ |
22+
C.precede(D); // C runs after D // +---->| C |-----+
23+
// +---+
24+
tf.wait_for_all(); // block until finished
2525

2626
return 0;
2727
}
28-

0 commit comments

Comments
 (0)