class
Taskflowmain entry to create a task dependency graph
Contents
A taskflow manages a task dependency graph where each task represents a callable object (e.g., lambda, std::
- static task: the callable constructible from
std::function<void()>
- dynamic task: the callable constructible from
std::function<void(tf::Subflow&)>
- condition task: the callable constructible from
std::function<int()>
- module task: the task constructed from tf::
Taskflow:: composed_of - cudaFlow task: the callable constructible from
std::function<void(tf::cudaFlow&)>
orstd::function<void(tf::cudaFlowCapturer&)>
The following example creates a simple taskflow graph of four static tasks, A
, B
, C
, and D
, where A
runs before B
and C
and D
runs after B
and C
.
tf::Executor executor; tf::Taskflow taskflow("simple"); auto [A, B, C, D] = taskflow.emplace( []() { std::cout << "TaskA\n"; }, []() { std::cout << "TaskB\n"; }, []() { std::cout << "TaskC\n"; }, []() { std::cout << "TaskD\n"; } ); A.precede(B, C); // A runs before B and C D.succeed(B, C); // D runs after B and C executor.run(taskflow).wait();
Please refer to Cookbook to learn more about each task type.
Base classes
- class FlowBuilder
- building methods of a task dependency graph
Constructors, destructors, conversion operators
-
Taskflow(const std::
string& name) - constructs a taskflow with the given name
- Taskflow()
- constructs a taskflow
Public functions
-
void dump(std::
ostream& ostream) const - dumps the taskflow to a DOT format through an output stream using the stream insertion operator
<<
-
auto dump() const -> std::
string - dumps the taskflow to a std::
string of DOT format - auto num_tasks() const -> size_t
- queries the number of tasks
- auto empty() const -> bool
- queries the emptiness of the taskflow
-
void name(const std::
string&) - sets the name of the taskflow
-
auto name() const -> const std::
string& - queries the name of the taskflow
- void clear()
- clears the associated task dependency graph
-
template<typename V>void for_each_task(V&& visitor) const
- applies an visitor callable to each task in the taskflow
Function documentation
template<typename V>
void tf:: Taskflow:: for_each_task(V&& visitor) const
applies an visitor callable to each task in the taskflow
The visitor is a callable that takes an argument of type tf::
taskflow.for_each_task([](tf::Task task){ std::cout << task.name() << '\n'; });