tf::Task
taskflow/core/task.hpp
class friend class FlowBuilder FlowBuilder tf::Task::FlowBuilder FlowBuilder
class friend class Runtime Runtime tf::Task::Runtime Runtime
class friend class Taskflow Taskflow tf::Task::Taskflow Taskflow
class friend class TaskView TaskView tf::Task::TaskView TaskView
class friend class Executor Executor tf::Task::Executor Executor
Node * Node* tf::Task::_node _node tf::Task::_node {nullptr}
tf::Task::Task
()=default
Task
tf::Task::Task

constructs an empty task

tf::Task::Task
(const Task &other)
Task
tf::Task::Task
const Task & other

constructs the task with the copy of the other task

Task & Task & tf::Task::operator= (const Task &) operator= tf::Task::operator= const Task & rhs

replaces the contents with a copy of the other task

Task & Task & tf::Task::operator= (std::nullptr_t) operator= tf::Task::operator= std::nullptr_t ptr

replaces the contents with a null pointer

bool bool tf::Task::operator== (const Task &rhs) const operator== tf::Task::operator== const Task & rhs

compares if two tasks are associated with the same graph node

bool bool tf::Task::operator!= (const Task &rhs) const operator!= tf::Task::operator!= const Task & rhs

compares if two tasks are not associated with the same graph node

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

queries the name of the task

size_t size_t tf::Task::num_successors () const num_successors tf::Task::num_successors

queries the number of successors of the task

size_t size_t tf::Task::num_dependents () const num_dependents tf::Task::num_dependents

queries the number of predecessors of the task

size_t size_t tf::Task::num_strong_dependents () const num_strong_dependents tf::Task::num_strong_dependents

queries the number of strong dependents of the task

size_t size_t tf::Task::num_weak_dependents () const num_weak_dependents tf::Task::num_weak_dependents

queries the number of weak dependents of the task

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

assigns a name to the task

name

a std::string acceptable string

`*this`

typename C
Task & Task & tf::Task::work (C &&callable) work tf::Task::work C && callable

assigns a callable

C

callable type

callable

callable to construct a task

`*this`

typename T
Task & Task & tf::Task::composed_of (T &object) composed_of tf::Task::composed_of T & object

creates a module task from a taskflow

T

object type

object

a custom object that defines `T::graph()` method

`*this`

typename... Ts Ts
Task & Task & tf::Task::precede (Ts &&... tasks) precede tf::Task::precede Ts &&... tasks

adds precedence links from this to other tasks

Ts

parameter pack

tasks

one or multiple tasks

`*this`

typename... Ts Ts
Task & Task & tf::Task::succeed (Ts &&... tasks) succeed tf::Task::succeed Ts &&... tasks

adds precedence links from other tasks to this

Ts

parameter pack

tasks

one or multiple tasks

`*this`

Task & Task & tf::Task::release (Semaphore &semaphore) release tf::Task::release Semaphore & semaphore

makes the task release this semaphore

typename I
Task & Task & tf::Task::release (I first, I last) release tf::Task::release I first I last

makes the task release the given range of semaphores

Task & Task & tf::Task::acquire (Semaphore &semaphore) acquire tf::Task::acquire Semaphore & semaphore

makes the task acquire this semaphore

typename I
Task & Task & tf::Task::acquire (I first, I last) acquire tf::Task::acquire I first I last

makes the task acquire the given range of semaphores

Task & Task & tf::Task::data (void *data) data tf::Task::data void * data

assigns pointer to user data

data

pointer to user data

The following example shows how to attach user data to a task and run the task iteratively while changing the data value:

    tf::Executorexecutor;
    tf::Taskflowtaskflow("attachdatatoatask");

    intdata;

    //createataskandattachitthedata
    autoA=taskflow.placeholder();
    A.data(&data).work([A](){
    autod=*static_cast<int*>(A.data());
    std::cout<<"datais"<<d<<std::endl;
    });

    //runthetaskflowiterativelywithchangingdata
    for(data=0;data<10;data++){
    executor.run(taskflow).wait();
    }

`*this`

void void tf::Task::reset () reset tf::Task::reset

resets the task handle to null

void void tf::Task::reset_work () reset_work tf::Task::reset_work

resets the associated work to a placeholder

bool bool tf::Task::empty () const empty tf::Task::empty

queries if the task handle points to a task node

bool bool tf::Task::has_work () const has_work tf::Task::has_work

queries if the task has a work assigned

typename V
void void tf::Task::for_each_successor (V &&visitor) const for_each_successor tf::Task::for_each_successor V && visitor

applies an visitor callable to each successor of the task

typename V
void void tf::Task::for_each_dependent (V &&visitor) const for_each_dependent tf::Task::for_each_dependent V && visitor

applies an visitor callable to each dependents of the task

size_t size_t tf::Task::hash_value () const hash_value tf::Task::hash_value

obtains a hash value of the underlying node

TaskType TaskType tf::Task::type () const type tf::Task::type

returns the task type

void void tf::Task::dump (std::ostream &ostream) const dump tf::Task::dump std::ostream & ostream

dumps the task through an output stream

void * void * tf::Task::data () const data tf::Task::data

queries pointer to user data

tf::Task::Task
(Node *)
Task
tf::Task::Task
Node * node

class to create a task handle over a node in a taskflow graph

A task is a wrapper over a node in a taskflow graph. It provides a set of methods for users to access and modify the attributes of the associated node in the taskflow graph. A task is very lightweight object (i.e., only storing a node pointer) that can be trivially copied around, and it does not own the lifetime of the associated node.

- tf::Task
  _node
- tf::Task
  acquire
- tf::Task
  acquire
- tf::Task
  composed_of
- tf::Task
  data
- tf::Task
  data
- tf::Task
  dump
- tf::Task
  empty
- tf::Task
  Executor
- tf::Task
  FlowBuilder
- tf::Task
  for_each_dependent
- tf::Task
  for_each_successor
- tf::Task
  has_work
- tf::Task
  hash_value
- tf::Task
  name
- tf::Task
  name
- tf::Task
  num_dependents
- tf::Task
  num_strong_dependents
- tf::Task
  num_successors
- tf::Task
  num_weak_dependents
- tf::Task
  operator!=
- tf::Task
  operator=
- tf::Task
  operator=
- tf::Task
  operator==
- tf::Task
  precede
- tf::Task
  release
- tf::Task
  release
- tf::Task
  reset
- tf::Task
  reset_work
- tf::Task
  Runtime
- tf::Task
  succeed
- tf::Task
  Task
- tf::Task
  Task
- tf::Task
  Task
- tf::Task
  Taskflow
- tf::Task
  TaskView
- tf::Task
  type
- tf::Task
  work