96 default: val =
"undefined";
break;
271 template <
typename C>
282 template <
typename T>
294 template <
typename... Ts>
306 template <
typename... Ts>
373 template <
typename V>
379 template <
typename V>
407 Node* _node {
nullptr};
419template <
typename... Ts>
421 (_node->_precede(tasks._node), ...);
427template <
typename... Ts>
429 (tasks._node->_precede(_node), ...);
437 _node->_handle.emplace<Node::Module>(object);
455 return _node == rhs._node;
460 return _node != rhs._node;
471 if(!_node->_semaphores) {
474 _node->_semaphores->to_acquire.push_back(&s);
480 if(!_node->_semaphores) {
484 _node->_semaphores->to_release.push_back(&s);
505 return _node->num_dependents();
510 return _node->num_strong_dependents();
515 return _node->num_weak_dependents();
520 return _node->num_successors();
525 return _node ==
nullptr;
530 return _node ? _node->_handle.index() != 0 :
false;
535 switch(_node->_handle.index()) {
554 for(
size_t i=0; i<_node->_successors.size(); ++i) {
555 visitor(
Task(_node->_successors[i]));
562 for(
size_t i=0; i<_node->_dependents.size(); ++i) {
563 visitor(
Task(_node->_dependents[i]));
584 if constexpr(is_static_task_v<C>) {
587 else if constexpr(is_dynamic_task_v<C>) {
590 else if constexpr(is_condition_task_v<C>) {
593 else if constexpr(is_multi_condition_task_v<C>) {
596 else if constexpr(is_cudaflow_task_v<C>) {
599 else if constexpr(is_runtime_task_v<C>) {
603 static_assert(dependent_false_v<C>,
"invalid task callable");
672 template <
typename V>
678 template <
typename V>
700inline TaskView::TaskView(
const Node& node) : _node {node} {
710 return _node.num_dependents();
715 return _node.num_strong_dependents();
720 return _node.num_weak_dependents();
725 return _node.num_successors();
730 switch(_node._handle.index()) {
754 for(
size_t i=0; i<_node._successors.size(); ++i) {
755 visitor(
TaskView(_node._successors[i]));
762 for(
size_t i=0; i<_node._dependents.size(); ++i) {
763 visitor(
TaskView(_node._dependents[i]));
777struct hash<
tf::Task> {
779 return task.hash_value();
789struct hash<
tf::TaskView> {
class to create an executor for running a taskflow graph
Definition executor.hpp:50
class to build a task dependency graph
Definition flow_builder.hpp:21
class to create a runtime object used by a runtime task
Definition graph.hpp:150
class to create a semophore object for building a concurrency constraint
Definition semaphore.hpp:68
class to access task information from the observer interface
Definition task.hpp:638
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition task.hpp:753
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition task.hpp:761
TaskType type() const
queries the task type
Definition task.hpp:729
size_t hash_value() const
obtains a hash value of the underlying node
Definition task.hpp:747
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition task.hpp:714
const std::string & name() const
queries the name of the task
Definition task.hpp:704
size_t num_dependents() const
queries the number of predecessors of the task
Definition task.hpp:709
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition task.hpp:719
size_t num_successors() const
queries the number of successors of the task
Definition task.hpp:724
class to create a task handle over a node in a taskflow graph
Definition task.hpp:187
Task & acquire(Semaphore &semaphore)
makes the task acquire this semaphore
Definition task.hpp:470
const std::string & name() const
queries the name of the task
Definition task.hpp:499
size_t num_successors() const
queries the number of successors of the task
Definition task.hpp:519
size_t hash_value() const
obtains a hash value of the underlying node
Definition task.hpp:568
Task & release(Semaphore &semaphore)
makes the task release this semaphore
Definition task.hpp:479
Task & work(C &&callable)
assigns a callable
Definition task.hpp:582
void reset()
resets the task handle to null
Definition task.hpp:489
void * data() const
queries pointer to user data
Definition task.hpp:609
void dump(std::ostream &ostream) const
dumps the task through an output stream
Definition task.hpp:573
Task & succeed(Ts &&... tasks)
adds precedence links from other tasks to this
Definition task.hpp:428
void for_each_dependent(V &&visitor) const
applies an visitor callable to each dependents of the task
Definition task.hpp:561
Task()=default
constructs an empty task
bool empty() const
queries if the task handle points to a task node
Definition task.hpp:524
Task & precede(Ts &&... tasks)
adds precedence links from this to other tasks
Definition task.hpp:420
size_t num_dependents() const
queries the number of predecessors of the task
Definition task.hpp:504
Task & composed_of(T &object)
creates a module task from a taskflow
Definition task.hpp:436
size_t num_strong_dependents() const
queries the number of strong dependents of the task
Definition task.hpp:509
bool operator==(const Task &rhs) const
compares if two tasks are associated with the same graph node
Definition task.hpp:454
Task & operator=(const Task &)
replaces the contents with a copy of the other task
Definition task.hpp:442
void reset_work()
resets the associated work to a placeholder
Definition task.hpp:494
TaskType type() const
returns the task type
Definition task.hpp:534
size_t num_weak_dependents() const
queries the number of weak dependents of the task
Definition task.hpp:514
bool operator!=(const Task &rhs) const
compares if two tasks are not associated with the same graph node
Definition task.hpp:459
bool has_work() const
queries if the task has a work assigned
Definition task.hpp:529
void for_each_successor(V &&visitor) const
applies an visitor callable to each successor of the task
Definition task.hpp:553
class to create a taskflow object
Definition core/taskflow.hpp:73
taskflow namespace
Definition small_vector.hpp:27
constexpr bool is_condition_task_v
determines if a callable is a condition task
Definition task.hpp:131
constexpr bool is_static_task_v
determines if a callable is a static task
Definition task.hpp:112
TaskType
enumeration of all task types
Definition task.hpp:21
@ UNDEFINED
undefined task type (for internal use only)
@ DYNAMIC
dynamic (subflow) task type
@ CUDAFLOW
cudaFlow task type
@ MULTI_CONDITION
multi-condition task type
@ CONDITION
condition task type
@ SYCLFLOW
syclFlow task type
@ ASYNC
asynchronous task type
@ PLACEHOLDER
placeholder task type
@ RUNTIME
runtime task type
const char * to_string(TaskType type)
convert a task type to a human-readable string
Definition task.hpp:81
constexpr bool is_dynamic_task_v
determines if a callable is a dynamic task
Definition task.hpp:123
constexpr bool is_syclflow_task_v
determines if a callable is a syclFlow task
Definition task.hpp:160
constexpr bool is_multi_condition_task_v
determines if a callable is a multi-condition task
Definition task.hpp:140
std::ostream & operator<<(std::ostream &os, const Task &task)
overload of ostream inserter operator for cudaTask
Definition task.hpp:626
constexpr bool is_cudaflow_task_v
determines if a callable is a cudaFlow task
Definition task.hpp:150
constexpr bool is_runtime_task_v
determines if a callable is a runtime task
Definition task.hpp:169