class to construct a subflow graph from the execution of a dynamic task More...
#include <taskflow/core/flow_builder.hpp>
Public Member Functions | |
| void | join () |
| enables the subflow to join its parent task | |
| bool | joinable () const noexcept |
| queries if the subflow is joinable | |
| Executor & | executor () noexcept |
| acquires the associated executor | |
| Graph & | graph () |
| acquires the associated graph | |
| void | retain (bool flag) noexcept |
| specifies whether to keep the subflow after it is joined | |
| bool | retain () const |
| queries if the subflow will be retained after it is joined | |
Public Member Functions inherited from tf::FlowBuilder | |
| FlowBuilder (Graph &graph) | |
| constructs a flow builder with a graph | |
| template<StaticTask C> | |
| Task | emplace (C &&callable) |
| creates a static task | |
| template<RuntimeTask C> | |
| Task | emplace (C &&callable) |
| creates a runtime task | |
| template<SubflowTask C> | |
| Task | emplace (C &&callable) |
| creates a dynamic task | |
| template<ConditionTask C> | |
| Task | emplace (C &&callable) |
| creates a condition task | |
| template<MultiConditionTask C> | |
| Task | emplace (C &&callable) |
| creates a multi-condition task | |
| template<typename... C> requires (sizeof...(C) > 1) | |
| auto | emplace (C &&... callables) |
| creates multiple tasks from a list of callable objects | |
| void | erase (Task task) |
| removes a task from a taskflow | |
| template<HasGraph T> | |
| Task | composed_of (T &object) |
| creates a module task for the target object | |
| Task | adopt (Graph &&graph) |
| creates a module task from a graph by taking over its ownership | |
| Task | placeholder () |
| creates a placeholder task | |
| void | linearize (std::vector< Task > &tasks) |
| adds adjacent dependency links to a linear list of tasks | |
| void | linearize (std::initializer_list< Task > tasks) |
| adds adjacent dependency links to a linear list of tasks | |
| template<typename B, typename E, typename C, Partitioner P = DefaultPartitioner> | |
| Task | for_each (B first, E last, C callable, P part=P()) |
| constructs an STL-styled parallel-for task | |
| template<typename B, typename E, typename S, typename C, Partitioner P = DefaultPartitioner> | |
| Task | for_each_index (B first, E last, S step, C callable, P part=P()) |
| constructs an index-based parallel-for task | |
| template<IndexRange1DLike R, typename C, Partitioner P = DefaultPartitioner> | |
| Task | for_each_by_index (R range, C callable, P part=P()) |
| constructs a parallel-for task over a one-dimensional index range | |
| template<IndexRangeMDLike R, typename C, Partitioner P = DefaultPartitioner> | |
| Task | for_each_by_index (R range, C callable, P part=P()) |
| constructs a parallel-for task over a multi-dimensional index range | |
| template<typename B, typename E, typename O, typename C, Partitioner P = DefaultPartitioner> | |
| Task | transform (B first1, E last1, O d_first, C c, P part=P()) |
| constructs a parallel-transform task | |
| template<typename B1, typename E1, typename B2, typename O, typename C, Partitioner P = DefaultPartitioner> requires (!Partitioner<std::decay_t<C>>) | |
| Task | transform (B1 first1, E1 last1, B2 first2, O d_first, C c, P part=P()) |
| constructs a parallel-transform task | |
| template<typename B, typename E, typename T, typename O, Partitioner P = DefaultPartitioner> | |
| Task | reduce (B first, E last, T &init, O bop, P part=P()) |
| constructs an STL-styled parallel-reduction task | |
| template<IndexRangeLike R, typename T, typename L, typename G, Partitioner P = DefaultPartitioner> | |
| Task | reduce_by_index (R range, T &init, L lop, G gop, P part=P()) |
| constructs an index range-based parallel-reduction task | |
| template<typename B, typename E, typename T, typename BOP, typename UOP, Partitioner P = DefaultPartitioner> | |
| Task | transform_reduce (B first, E last, T &init, BOP bop, UOP uop, P part=P()) |
| constructs an STL-styled parallel transform-reduce task | |
| template<typename B1, typename E1, typename B2, typename T, typename BOP_R, typename BOP_T, Partitioner P = DefaultPartitioner> requires (!Partitioner<std::decay_t<BOP_T>>) | |
| Task | transform_reduce (B1 first1, E1 last1, B2 first2, T &init, BOP_R bop_r, BOP_T bop_t, P part=P()) |
| constructs an STL-styled parallel transform-reduce task | |
| template<typename B, typename E, typename D, typename BOP> | |
| Task | inclusive_scan (B first, E last, D d_first, BOP bop) |
| creates an STL-styled parallel inclusive-scan task | |
| template<typename B, typename E, typename D, typename BOP, typename T> | |
| Task | inclusive_scan (B first, E last, D d_first, BOP bop, T init) |
| creates an STL-styled parallel inclusive-scan task with an initial value | |
| template<typename B, typename E, typename D, typename T, typename BOP> | |
| Task | exclusive_scan (B first, E last, D d_first, T init, BOP bop) |
| creates an STL-styled parallel exclusive-scan task | |
| template<typename B, typename E, typename D, typename BOP, typename UOP> | |
| Task | transform_inclusive_scan (B first, E last, D d_first, BOP bop, UOP uop) |
| creates an STL-styled parallel transform-inclusive scan task | |
| template<typename B, typename E, typename D, typename BOP, typename UOP, typename T> | |
| Task | transform_inclusive_scan (B first, E last, D d_first, BOP bop, UOP uop, T init) |
| creates an STL-styled parallel transform-inclusive scan task | |
| template<typename B, typename E, typename D, typename T, typename BOP, typename UOP> | |
| Task | transform_exclusive_scan (B first, E last, D d_first, T init, BOP bop, UOP uop) |
| creates an STL-styled parallel transform-exclusive scan task | |
| template<typename B, typename E, typename T, typename UOP, Partitioner P = DefaultPartitioner> | |
| Task | find_if (B first, E last, T &result, UOP predicate, P part=P()) |
| constructs a task to perform STL-styled find-if algorithm | |
| template<typename B, typename E, typename T, typename UOP, Partitioner P = DefaultPartitioner> | |
| Task | find_if_not (B first, E last, T &result, UOP predicate, P part=P()) |
| constructs a task to perform STL-styled find-if-not algorithm | |
| template<typename B, typename E, typename T, typename C, Partitioner P> | |
| Task | min_element (B first, E last, T &result, C comp, P part) |
| constructs a task to perform STL-styled min-element algorithm | |
| template<typename B, typename E, typename T, typename C, Partitioner P> | |
| Task | max_element (B first, E last, T &result, C comp, P part) |
| constructs a task to perform STL-styled max-element algorithm | |
| template<typename B, typename E, typename C> | |
| Task | sort (B first, E last, C cmp) |
| constructs a dynamic task to perform STL-styled parallel sort | |
| template<typename B, typename E> | |
| Task | sort (B first, E last) |
constructs a dynamic task to perform STL-styled parallel sort using the std::less<T> comparator, where T is the element type | |
| template<typename B1, typename E1, typename B2, typename E2, typename O, Partitioner P = DefaultPartitioner> | |
| Task | merge (B1 first1, E1 last1, B2 first2, E2 last2, O d_first, P part=P()) |
merges two sorted ranges into a single sorted output using the std::less comparator | |
| template<typename B1, typename E1, typename B2, typename E2, typename O, typename C, Partitioner P = DefaultPartitioner> requires (!Partitioner<std::decay_t<C>>) | |
| Task | merge (B1 first1, E1 last1, B2 first2, E2 last2, O d_first, C cmp, P part=P()) |
| merges two sorted ranges into a single sorted output using the supplied comparator | |
| template<typename B, typename E, typename V, typename P = DefaultPartitioner> requires Partitioner<std::decay_t<P>> | |
| Task | fill (B first, E last, V value, P part=P()) |
| fills a range with a given value in parallel | |
| template<typename B, typename C, typename V, typename P = DefaultPartitioner> requires (Partitioner<std::decay_t<P>> && std::integral<C>) | |
| Task | fill_n (B first, C count, V value, P part=P()) |
| fills N elements with a given value in parallel | |
| template<typename B, typename E, typename G, typename P = DefaultPartitioner> requires Partitioner<std::decay_t<P>> | |
| Task | generate (B first, E last, G gen, P part=P()) |
| generates values into a range in parallel using a callable | |
| template<typename B, typename C, typename G, typename P = DefaultPartitioner> requires (Partitioner<std::decay_t<P>> && std::integral<C>) | |
| Task | generate_n (B first, C count, G gen, P part=P()) |
| generates N values into a range in parallel using a callable | |
Friends | |
| class | Executor |
| class | FlowBuilder |
class to construct a subflow graph from the execution of a dynamic task
tf::Subflow is spawned from the execution of a task to dynamically manage a child graph that may depend on runtime variables. You can explicitly join a subflow by calling tf::Subflow::join, respectively. By default, the Taskflow runtime will implicitly join a subflow it is is joinable.
The following example creates a taskflow graph that spawns a subflow from the execution of task B, and the subflow contains three tasks, B1, B2, and B3, where B3 runs after B1 and B2.
| void tf::Subflow::join | ( | ) |
enables the subflow to join its parent task
Performs an immediate action to join the subflow. Once the subflow is joined, it is considered finished and you may not modify the subflow anymore.
Only the worker that spawns this subflow can join it.
|
inlinenoexcept |
queries if the subflow is joinable
This member function queries if the subflow is joinable. When a subflow is joined, it becomes not joinable.
|
inline |
queries if the subflow will be retained after it is joined
true if the subflow will be retained after it is joined; false otherwiseBy default, the runtime automatically clears a spawned subflow once it is joined. Users can disable this before by explicitly calling tf::Subflow::retain.
|
inlinenoexcept |
specifies whether to keep the subflow after it is joined
| flag | true to retain the subflow after it is joined; false to discard it |
By default, the runtime automatically clears a spawned subflow once it is joined. Setting this flag to true allows the application to retain the subflow's structure for post-execution analysis like visualization.