Cpp-Taskflow  2.3.0
tf::Task Class Reference

task handle to a node in a task dependency graph More...

#include <task.hpp>

Public Member Functions

 Task ()=default
 constructs an empty task
 
 Task (const Task &other)
 constructs the task with the copy of the other task
 
Task & operator= (const Task &)
 replaces the contents with a copy of the other task
 
Task & operator= (std::nullptr_t)
 replaces the contents with a null pointer
 
bool operator== (const Task &rhs) const
 compares if two tasks are associated with the same graph node
 
bool operator!= (const Task &rhs) const
 compares if two tasks are not associated with the same graph node
 
const std::string & name () const
 queries the name of the task
 
size_t num_successors () const
 queries the number of successors of the task
 
size_t num_dependents () const
 queries the number of predecessors of the task
 
size_t num_strong_dependents () const
 queries the number of strong dependents of the task
 
size_t num_weak_dependents () const
 queries the number of weak dependents of the task
 
Task & name (const std::string &name)
 assigns a name to the task More...
 
template<typename C >
Task & work (C &&callable)
 assigns a new callable object to the task More...
 
template<typename... Ts>
Task & precede (Ts &&... tasks)
 adds precedence links from this to other tasks More...
 
template<typename... Ts>
Task & succeed (Ts &&... tasks)
 adds precedence links from other tasks to this More...
 
Task & reset ()
 resets the task handle to null More...
 
bool empty () const
 queries if the task handle points to a task node
 
bool has_work () const
 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
 

Friends

class FlowBuilder
 
class Taskflow
 
class TaskView
 

Detailed Description

task handle to a node in a task dependency graph

A Task is a wrapper of a node in a dependency graph. It provides a set of methods for users to access and modify the attributes of the task node, preventing direct access to the internal data storage.

Member Function Documentation

◆ name()

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

assigns a name to the task

Parameters
namea std::string acceptable string
Returns
*this

◆ precede()

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

adds precedence links from this to other tasks

Template Parameters
Ts...parameter pack
Parameters
tasksone or multiple tasks
Returns
*this

◆ reset()

Task & tf::Task::reset ( )
inline

resets the task handle to null

Returns
*this

◆ succeed()

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

adds precedence links from other tasks to this

Template Parameters
Tsparameter pack
Parameters
tasksone or multiple tasks
Returns
*this

◆ work()

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

assigns a new callable object to the task

Template Parameters
Ccallable object type
Parameters
callablea callable object acceptable to std::function
Returns
*this

The documentation for this class was generated from the following files: