File: simple_dsl.cpp

package info (click to toggle)
taskflow 3.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 45,948 kB
  • sloc: cpp: 39,058; xml: 35,572; python: 12,935; javascript: 1,732; makefile: 59; sh: 16
file content (28 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download
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
// 2020/08/28 - Created by netcan: https://github.com/netcan
// A simple example to capture the following task dependencies.
// using Task DSL to describe
// TaskA -> fork(TaskB, TaskC) -> TaskD
#include <taskflow/taskflow.hpp>     // the only include you need
#include <taskflow/dsl.hpp> // for support dsl

int main() {
  tf::Executor executor;
  tf::Taskflow taskflow("simple");
  make_task((A), { std::cout << "TaskA\n"; });
  make_task((B), { std::cout << "TaskB\n"; });
  make_task((C), { std::cout << "TaskC\n"; });
  make_task((D), { std::cout << "TaskD\n"; });

  build_taskflow(           //          +---+
    task(A)                 //    +---->| B |-----+
      ->fork_tasks(B, C)    //    |     +---+     |
      ->task(D)             //  +---+           +-v-+
  )(taskflow);              //  | A |           | D |
                            //  +---+           +-^-+
                            //    |     +---+     |
                            //    +---->| C |-----+
                            //          +---+

  executor.run(taskflow).wait();
  return 0;
}