|
| | Task ()=default |
| | constructs an empty task
|
| |
| | Task (const Task &other) |
| | constructs the task with the copy of the other task
|
| |
| Task & | operator= (const Task &other) |
| | 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 taskflow node
|
| |
| bool | operator!= (const Task &rhs) const |
| | compares if two tasks are not associated with the same taskflow 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_predecessors () const |
| | queries the number of predecessors of the task
|
| |
| size_t | num_strong_dependencies () const |
| | queries the number of strong dependencies of the task
|
| |
| size_t | num_weak_dependencies () const |
| | queries the number of weak dependencies of the task
|
| |
| Task & | name (const std::string &name) |
| | assigns a name to the task
|
| |
| template<typename C> |
| Task & | work (C &&callable) |
| | assigns a callable
|
| |
| template<HasGraph T> |
| Task & | composed_of (T &object) |
| | creates a module task from a taskflow
|
| |
| Task & | adopt (tf::Graph &&graph) |
| | creates an adopted module task from the given graph with move semantics
|
| |
| template<typename... Ts> |
| Task & | precede (Ts &&... tasks) |
| | adds precedence links from this to other tasks
|
| |
| template<typename... Ts> |
| Task & | succeed (Ts &&... tasks) |
| | adds precedence links from other tasks to this
|
| |
| template<typename... Ts> |
| Task & | remove_predecessors (Ts &&... tasks) |
| | removes predecessor links from other tasks to this
|
| |
| template<typename... Ts> |
| Task & | remove_successors (Ts &&... tasks) |
| | removes successor links from this to other tasks
|
| |
| Task & | release (Semaphore &semaphore) |
| | makes the task release the given semaphore
|
| |
| template<typename I> |
| Task & | release (I first, I last) |
| | makes the task release the given range of semaphores
|
| |
| Task & | acquire (Semaphore &semaphore) |
| | makes the task acquire the given semaphore
|
| |
| template<typename I> |
| Task & | acquire (I first, I last) |
| | makes the task acquire the given range of semaphores
|
| |
| Task & | data (void *data) |
| | assigns pointer to user data
|
| |
| void | reset () |
| | resets the task handle to null
|
| |
|
void | reset_work () |
| | resets the associated work to a placeholder
|
| |
| bool | empty () const |
| | queries if the task handle is associated with a taskflow 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_predecessor (V &&visitor) const |
| | applies an visitor callable to each predecessor of the task
|
| |
| template<typename V> |
| void | for_each_subflow_task (V &&visitor) const |
| | applies an visitor callable to each subflow task
|
| |
| size_t | hash_value () const |
| | obtains a hash value of the underlying node
|
| |
| TaskType | type () const |
| | returns the task type
|
| |
| void | dump (std::ostream &ostream) const |
| | dumps the task through an output stream
|
| |
| void * | data () const |
| | queries pointer to user data
|
| |
| std::exception_ptr | exception_ptr () const |
| | retrieves the exception pointer of this task
|
| |
| bool | has_exception_ptr () const |
| | queries if the task has an exception pointer
|
| |
class to create a task handle over a taskflow node
A task points to a node in a taskflow graph and provides a set of methods for users to access and modify attributes of the associated node, such as dependencies, callable, names, and so on. A task is a very lightweight object (i.e., it only stores a node pointer) and can be trivially copied around.
auto task1 = taskflow.emplace([](){}).
name(
"task1");
auto task2 = taskflow.emplace([](){}).
name(
"task2");
task1.precede(task2);
task1.dump(std::cout);
const std::string & name() const
queries the name of the task
Definition task.hpp:1077
A task created from a taskflow can be one of the following types:
tf::Task task1 = taskflow.emplace([](){}).
name(
"static task");
tf::Task task2 = taskflow.emplace([](){
return 3; }).
name(
"condition task");
tf::Task task4 = taskflow.emplace([](tf::Subflow& sf){
tf::Task stask1 = sf.
emplace([](){});
tf::Task stask2 = sf.
emplace([](){});
Task emplace(C &&callable)
creates a static task
Definition flow_builder.hpp:1352
class to create a runtime task
Definition runtime.hpp:47
class to create a task handle over a taskflow node
Definition task.hpp:263
Task & composed_of(T &object)
creates a module task from a taskflow
Definition task.hpp:979
A tf::Task is polymorphic. Once created, you can assign a different task type to it using tf::Task::work. For example, the code below creates a static task and then reworks it to a subflow task:
tf::Task task = taskflow.emplace([](){}).
name(
"static task");
class to construct a subflow graph from the execution of a dynamic task
Definition flow_builder.hpp:1516
Task & work(C &&callable)
assigns a callable
Definition task.hpp:1180
- Attention
- tf::Task does not own the lifetime of the associated node. Accessing the attributes of the associated node after the taskflow has been destroyed can result in undefined behavior.
| std::exception_ptr tf::Task::exception_ptr |
( |
| ) |
const |
|
inline |
retrieves the exception pointer of this task
This method retrieves the exception pointer of this task that are silently caught by the executor, if any. When multiple tasks throw exceptions concurrently, only one exception will be propagated, while the others are silently caught and stored within their respective tasks. For example, in the code below, both tasks B and C throw exceptions. However, only one of them will be propagated to the try-catch block, while the other will be silently caught and stored within its respective task.
std::atomic<size_t> arrivals(0);
[&]() {
++arrivals; while(arrivals != 2);
throw std::runtime_error("oops");
},
[&]() {
++arrivals; while(arrivals != 2);
throw std::runtime_error("oops");
}
);
try {
executor.run(taskflow).get();
}
catch (const std::runtime_error& e) {
std::cerr << e.what();
}
assert((B.exception_ptr() != nullptr) != (C.exception_ptr() != nullptr));