GitHub Viewer
/**
This program demonstrates how to traverse a graph using task visitor.
We first create four tasks: A, B, C, and D, where task A runs before B and C,
and task D runs after B and C. During the execution of B, it spawns another subflow
graph of three tasks: B1, B2, and B3, where B3 runs after B1 and B2.
Upon completion of the subflow, it joins its parent task B.
By default, subflows are automatically cleaned up when they finish to avoid memory explosion.
In this example, since we would like to inspect the spawned subflow,
we disable this behavior by calling `tf::Subflow::retain(true)`.
Note that we must run the subflow once for it to be created.
*/
#include
int main() {
// Create a taskflow graph with three static tasks and one subflow task.
tf::Taskflow taskflow("visitor");
tf::Executor executor;
auto A = taskflow.emplace([]() { std::cout