Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
2 contributors

Users who have contributed to this file

@tsung-wei-huang @clin99
31 lines (21 sloc) 1.11 KB
// A simple example to capture the following task dependencies.
//
// TaskA---->TaskB---->TaskD
// TaskA---->TaskC---->TaskD
#include <taskflow/taskflow.hpp> // the only include you need
int main(){
tf::Taskflow taskflow;
auto [A, B, C, D] = taskflow.emplace(
[] () { std::cout << "TaskA\n"; }, //
[] () { std::cout << "TaskB\n"; }, // +---+
[] () { std::cout << "TaskC\n"; }, // +---->| B |-----+
[] () { std::cout << "TaskD\n"; } // | +---+ |
); // +---+ +-v-+
// | A | | D |
A.precede(B); // B runs after A // +---+ +-^-+
A.precede(C); // C runs after A // | +---+ |
B.precede(D); // D runs after B // +---->| C |-----+
C.precede(D); // D runs after C // +---+
tf::Executor().run(taskflow); // create an executor to run the taskflow
return 0;
}
You can’t perform that action at this time.