17 constexpr
bool is_static_task_v = is_invocable_r_v<void, C> &&
18 !is_invocable_r_v<int, C>;
26 constexpr
bool is_dynamic_task_v = is_invocable_r_v<void, C, Subflow&>;
34 constexpr
bool is_condition_task_v = is_invocable_r_v<int, C>;
132 template <
typename C>
133 std::enable_if_t<is_static_task_v<C>,
Task>&
work(C&& callable);
144 template <
typename C>
145 std::enable_if_t<is_dynamic_task_v<C>,
Task>&
work(C&& callable);
156 template <
typename C>
157 std::enable_if_t<is_condition_task_v<C>,
Task>&
work(C&& callable);
177 template <
typename... Ts>
189 template <
typename... Ts>
215 template <
typename V>
221 template <
typename V>
228 Node* _node {
nullptr};
230 template <
typename T>
233 template <
typename T,
typename... Rest>
234 void _precede(T&&, Rest&&...);
236 template <
typename T>
239 template <
typename T,
typename... Rest>
240 void _succeed(T&&, Rest&&...);
244 inline Task::Task(Node* node) : _node {node} {
252 template <
typename... Ts>
255 _precede(std::forward<Ts>(tasks)...);
261 template <
typename T>
262 void Task::_precede(T&& other) {
263 _node->_precede(other._node);
268 template <
typename T,
typename... Ts>
269 void Task::_precede(T&& task, Ts&&... others) {
270 _precede(std::forward<T>(task));
271 _precede(std::forward<Ts>(others)...);
275 template <
typename... Ts>
278 _succeed(std::forward<Ts>(tasks)...);
284 template <
typename T>
285 void Task::_succeed(T&& other) {
286 other._node->_precede(_node);
291 template <
typename T,
typename... Ts>
292 void Task::_succeed(T&& task, Ts&&... others) {
293 _succeed(std::forward<T>(task));
294 _succeed(std::forward<Ts>(others)...);
299 _node->_handle.emplace<Node::ModuleWork>(&
tf);
317 return _node == rhs._node;
322 return _node != rhs._node;
338 _node->_handle = nstd::monostate{};
348 return _node->num_dependents();
353 return _node->num_strong_dependents();
358 return _node->num_weak_dependents();
363 return _node->num_successors();
368 return _node ==
nullptr;
373 return _node ? _node->_handle.index() != 0 :
false;
377 template <
typename V>
379 for(
size_t i=0; i<_node->_successors.size(); ++i) {
380 visitor(
Task(_node->_successors[i]));
385 template <
typename V>
387 for(
size_t i=0; i<_node->_dependents.size(); ++i) {
388 visitor(
Task(_node->_dependents[i]));
484 template <
typename V>
490 template <
typename V>
497 Node* _node {
nullptr};
537 return _node->num_dependents();
542 return _node->num_strong_dependents();
547 return _node->num_weak_dependents();
552 return _node->num_successors();
562 return _node ==
nullptr;
567 return _node == rhs._node;
572 return _node != rhs._node;
576 template <
typename V>
578 for(
size_t i=0; i<_node->_successors.size(); ++i) {
579 visitor(
TaskView(_node->_successors[i]));
584 template <
typename V>
586 for(
size_t i=0; i<_node->_dependents.size(); ++i) {
587 visitor(
TaskView(_node->_dependents[i]));
size_t num_dependents() const
queries the number of predecessors of the task
Definition: task.hpp:347
void reset_work()
resets the associated work to a placeholder
Definition: task.hpp:337
void reset()
resets the task handle to null
Definition: task.hpp:332
TaskView()=default
constructs an empty task view
bool operator!=(const TaskView &) const
compares if two taskviews are associated with different tasks
Definition: task.hpp:571
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition: task.hpp:585
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition: task.hpp:546
Task & composed_of(Taskflow &taskflow)
creates a module task from a taskflow
Definition: task.hpp:298
size_t num_successors() const
queries the number of successors of the task
Definition: task.hpp:551
bool operator==(const Task &rhs) const
compares if two tasks are associated with the same graph node
Definition: task.hpp:316
std::enable_if_t< is_static_task_v< C >, Task > & work(C &&callable)
assigns a static task
Definition: flow_builder.hpp:969
Task & succeed(Ts &&... tasks)
adds precedence links from other tasks to this
Definition: task.hpp:276
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition: task.hpp:577
bool operator!=(const Task &rhs) const
compares if two tasks are not associated with the same graph node
Definition: task.hpp:321
bool empty() const
queries if the task view is empty
Definition: task.hpp:561
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition: task.hpp:541
Task & operator=(const Task &)
replaces the contents with a copy of the other task
Definition: task.hpp:304
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition: task.hpp:386
the class to create a task dependency graph
Definition: taskflow.hpp:18
const std::string & name() const
queries the name of the task
Definition: task.hpp:342
an immutable accessor class to a task node, mainly used in the tf::ExecutorObserver interface...
Definition: task.hpp:400
bool empty() const
queries if the task handle points to a task node
Definition: task.hpp:367
void reset()
resets to an empty view
Definition: task.hpp:556
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition: task.hpp:352
Building methods 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:362
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition: task.hpp:357
handle to a node in a task dependency graph
Definition: task.hpp:51
Task & precede(Ts &&... tasks)
adds precedence links from this to other tasks
Definition: task.hpp:253
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition: task.hpp:378
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:513
bool operator==(const TaskView &) const
compares if two taskviews are associated with the same task
Definition: task.hpp:566
size_t num_dependents() const
queries the number of predecessors of the task
Definition: task.hpp:536
bool has_work() const
queries if the task has a work assigned
Definition: task.hpp:372
const std::string & name() const
queries the name of the task
Definition: task.hpp:531