tf::Task class

handle to a node in a task dependency graph

A Task is handle to manipulate a node in a taskflow graph. It provides a set of methods for users to access and modify the attributes of the associated graph node without directly touching internal node data.

Constructors, destructors, conversion operators

Task() defaulted
constructs an empty task
Task(const Task& other)
constructs the task with the copy of the other task

Public functions

auto operator=(const Task&) -> Task&
replaces the contents with a copy of the other task
auto operator=(std::nullptr_t) -> Task&
replaces the contents with a null pointer
auto operator==(const Task& rhs) const -> bool
compares if two tasks are associated with the same graph node
auto operator!=(const Task& rhs) const -> bool
compares if two tasks are not associated with the same graph node
auto name() const -> const std::string&
queries the name of the task
auto num_successors() const -> size_t
queries the number of successors of the task
auto num_dependents() const -> size_t
queries the number of predecessors of the task
auto num_strong_dependents() const -> size_t
queries the number of strong dependents of the task
auto num_weak_dependents() const -> size_t
queries the number of weak dependents of the task
auto name(const std::string& name) -> Task&
assigns a name to the task
template<typename C>
auto work(C&& callable) -> Task&
assigns a callable
auto composed_of(Taskflow& taskflow) -> Task&
creates a module task from a taskflow
template<typename... Ts>
auto precede(Ts && ... tasks) -> Task&
adds precedence links from this to other tasks
template<typename... Ts>
auto succeed(Ts && ... tasks) -> Task&
adds precedence links from other tasks to this
auto release(Semaphore& semaphore) -> Task&
makes the task release this semaphore
auto acquire(Semaphore& semaphore) -> Task&
makes the task acquire this semaphore
void reset()
resets the task handle to null
void reset_work()
resets the associated work to a placeholder
auto empty() const -> bool
queries if the task handle points to a task node
auto has_work() const -> bool
queries if the task has a work assigned
template<typename V>
void for_each_successor(V&& visitor) const
applies an visitor callable to each successor of the task
template<typename V>
void for_each_dependent(V&& visitor) const
applies an visitor callable to each dependents of the task
auto hash_value() const -> size_t
obtains a hash value of the underlying node
auto type() const -> TaskType
returns the task type
void dump(std::ostream& ostream) const
dumps the task through an output stream

Function documentation

Task& tf::Task::name(const std::string& name)

assigns a name to the task

Parameters
name a acceptable string
Returns *this

template<typename C>
Task& tf::Task::work(C&& callable)

assigns a callable

Template parameters
C callable type
Parameters
callable callable to construct one of the static, dynamic, condition, and cudaFlow tasks
Returns *this

Task& tf::Task::composed_of(Taskflow& taskflow)

creates a module task from a taskflow

Parameters
taskflow a taskflow object for the module
Returns *this

template<typename... Ts>
Task& tf::Task::precede(Ts && ... tasks)

adds precedence links from this to other tasks

Template parameters
Ts parameter pack
Parameters
tasks one or multiple tasks
Returns *this

template<typename... Ts>
Task& tf::Task::succeed(Ts && ... tasks)

adds precedence links from other tasks to this

Template parameters
Ts parameter pack
Parameters
tasks one or multiple tasks
Returns *this