103 template <
typename C>
115 template <
typename... Ts>
127 template <
typename... Ts>
150 template <
typename V>
156 template <
typename V>
164 Node* _node {
nullptr};
166 template <
typename S>
169 template <
typename S>
172 template <
typename S>
177 inline Task::Task(Node& node) : _node {&node} {
181 inline Task::Task(Node* node) : _node {node} {
189 template <
typename... Ts>
191 (_node->_precede(tgts._node), ...);
196 template <
typename... Bs>
198 (tgts._node->_precede(_node), ...);
216 return _node == rhs._node;
221 return _node != rhs._node;
243 return _node->num_dependents();
248 return _node->num_strong_dependents();
253 return _node->num_weak_dependents();
258 return _node->num_successors();
263 return _node ==
nullptr;
268 return _node ? _node->_work.index() != 0 :
false;
272 template <
typename V>
274 for(
size_t i=0; i<_node->_successors.size(); ++i) {
275 visitor(
Task(_node->_successors[i]));
280 template <
typename V>
282 for(
size_t i=0; i<_node->_dependents.size(); ++i) {
283 visitor(
Task(_node->_dependents[i]));
380 template <
typename V>
386 template <
typename V>
393 Node* _node {
nullptr};
433 return _node->num_dependents();
438 return _node->num_strong_dependents();
443 return _node->num_weak_dependents();
448 return _node->num_successors();
458 return _node ==
nullptr;
463 return _node == rhs._node;
468 return _node != rhs._node;
472 template <
typename V>
474 for(
size_t i=0; i<_node->_successors.size(); ++i) {
475 visitor(
TaskView(_node->_successors[i]));
480 template <
typename V>
482 for(
size_t i=0; i<_node->_dependents.size(); ++i) {
483 visitor(
TaskView(_node->_dependents[i]));
size_t num_dependents() const
queries the number of predecessors of the task
Definition: task.hpp:242
Task & reset()
resets the task handle to null
Definition: task.hpp:231
TaskView()=default
constructs an empty task view
bool operator!=(const TaskView &) const
compares if two taskviews are associated with different tasks
Definition: task.hpp:467
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition: task.hpp:481
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition: task.hpp:442
size_t num_successors() const
queries the number of successors of the task
Definition: task.hpp:447
Definition: taskflow.hpp:5
bool operator==(const Task &rhs) const
compares if two tasks are associated with the same graph node
Definition: task.hpp:215
Task & succeed(Ts &&... tasks)
adds precedence links from other tasks to this
Definition: task.hpp:197
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition: task.hpp:473
bool operator!=(const Task &rhs) const
compares if two tasks are not associated with the same graph node
Definition: task.hpp:220
bool empty() const
queries if the task view is empty
Definition: task.hpp:457
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition: task.hpp:437
Task & operator=(const Task &)
replaces the contents with a copy of the other task
Definition: task.hpp:203
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition: task.hpp:281
the class to create a task dependency graph
Definition: core/taskflow.hpp:18
const std::string & name() const
queries the name of the task
Definition: task.hpp:237
an immutable accessor class to a task node, mainly used in the tf::ExecutorObserver interface...
Definition: task.hpp:296
bool empty() const
queries if the task handle points to a task node
Definition: task.hpp:262
void reset()
resets to an empty view
Definition: task.hpp:452
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition: task.hpp:247
Building blocks of a task dependency graph.
Definition: flow_builder.hpp:13
size_t num_successors() const
queries the number of successors of the task
Definition: task.hpp:257
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition: task.hpp:252
task handle to a node in a task dependency graph
Definition: task.hpp:22
Task & precede(Ts &&... tasks)
adds precedence links from this to other tasks
Definition: task.hpp:190
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition: task.hpp:273
Task()=default
constructs an empty task
The executor class to run a taskflow graph.
Definition: executor.hpp:33
TaskView & operator=(const TaskView &other)
replaces the contents with a copy of the other task
Definition: task.hpp:409
bool operator==(const TaskView &) const
compares if two taskviews are associated with the same task
Definition: task.hpp:462
size_t num_dependents() const
queries the number of predecessors of the task
Definition: task.hpp:432
Task & work(C &&callable)
assigns a new callable object to the task
Definition: flow_builder.hpp:971
bool has_work() const
queries if the task has a work assigned
Definition: task.hpp:267
const std::string & name() const
queries the name of the task
Definition: task.hpp:427