17 #ifndef __TBB_flow_graph_H
18 #define __TBB_flow_graph_H
20 #define __TBB_flow_graph_H_include_area
38 #if TBB_USE_THREADING_TOOLS && TBB_PREVIEW_FLOW_GRAPH_TRACE && ( __linux__ || __APPLE__ )
41 #pragma warning (push)
42 #pragma warning( disable: 2196 )
44 #define __TBB_NOINLINE_SYM __attribute__((noinline))
46 #define __TBB_NOINLINE_SYM
49 #if __TBB_PREVIEW_ASYNC_MSG
54 #if __TBB_PREVIEW_STREAMING_NODE
57 #include <unordered_map>
58 #include <type_traits>
59 #endif // __TBB_PREVIEW_STREAMING_NODE
61 #if TBB_DEPRECATED_FLOW_ENQUEUE
62 #define FLOW_SPAWN(a) tbb::task::enqueue((a))
64 #define FLOW_SPAWN(a) tbb::task::spawn((a))
67 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
68 #define __TBB_DEFAULT_NODE_ALLOCATOR(T) cache_aligned_allocator<T>
70 #define __TBB_DEFAULT_NODE_ALLOCATOR(T) null_type
74 #if __TBB_CPP11_TUPLE_PRESENT
79 using std::tuple_size;
80 using std::tuple_element;
85 #include "compat/tuple"
107 namespace interface11 {
126 template<
typename T,
typename M>
class successor_cache;
128 template<
typename T,
typename M>
class round_robin_cache;
132 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
137 template<
typename Order,
typename... Args>
struct node_set;
140 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
144 class edge_container {
147 typedef std::list<C *, tbb::tbb_allocator<C *> > edge_list_type;
149 void add_edge(C &
s) {
150 built_edges.push_back(&s);
153 void delete_edge(C &s) {
154 for (
typename edge_list_type::iterator i = built_edges.begin(); i != built_edges.end(); ++i) {
162 void copy_edges(edge_list_type &v) {
166 size_t edge_count() {
167 return (
size_t)(built_edges.size());
176 template<
typename S >
void sender_extract(
S &s);
177 template<
typename R >
void receiver_extract(R &r);
180 edge_list_type built_edges;
195 namespace interface11 {
200 if (right == NULL)
return left;
202 if (left == NULL)
return right;
213 #if __TBB_PREVIEW_ASYNC_MSG
221 template<
typename T,
typename =
void >
229 return static_cast<const void*
>(&t);
233 return static_cast<void*
>(&t);
237 return *
static_cast<const T*
>(
p);
241 return *
static_cast<T*
>(
p);
262 template<
typename T >
303 class untyped_receiver;
330 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
331 typedef internal::edge_container<successor_type> built_successors_type;
333 typedef built_successors_type::edge_list_type successor_list_type;
334 virtual built_successors_type &built_successors() = 0;
335 virtual void internal_add_built_successor(
successor_type & ) = 0;
337 virtual void copy_successors( successor_list_type &) = 0;
338 virtual size_t successor_count() = 0;
342 template<
typename X >
348 template<
typename X >
364 #if __TBB_PREVIEW_OPENCL_NODE
378 if (!res)
return false;
393 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
394 typedef internal::edge_container<predecessor_type> built_predecessors_type;
395 typedef built_predecessors_type::edge_list_type predecessor_list_type;
396 virtual built_predecessors_type &built_predecessors() = 0;
399 virtual void copy_predecessors( predecessor_list_type & ) = 0;
400 virtual size_t predecessor_count() = 0;
423 template<
typename T >
444 __TBB_ASSERT(
false,
"async_msg interface does not support 'pull' protocol in try_get()");
454 __TBB_ASSERT(
false,
"async_msg interface does not support 'pull' protocol in try_reserve()");
460 template<
typename T >
489 #else // __TBB_PREVIEW_ASYNC_MSG
492 template<
typename T >
523 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
524 __TBB_DEPRECATED typedef typename internal::edge_container<successor_type> built_successors_type;
526 __TBB_DEPRECATED typedef typename built_successors_type::edge_list_type successor_list_type;
536 template<
typename T >
551 if (!res)
return false;
572 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
573 __TBB_DEPRECATED typedef typename internal::edge_container<predecessor_type> built_predecessors_type;
574 __TBB_DEPRECATED typedef typename built_predecessors_type::edge_list_type predecessor_list_type;
589 #if __TBB_PREVIEW_OPENCL_NODE
594 #endif // __TBB_PREVIEW_ASYNC_MSG
639 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
640 __TBB_DEPRECATED typedef internal::edge_container<predecessor_type> built_predecessors_type;
642 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
646 my_built_predecessors.add_edge( s );
651 my_built_predecessors.delete_edge(s);
656 my_built_predecessors.copy_edges(v);
661 return my_built_predecessors.edge_count();
683 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
686 built_predecessors_type my_built_predecessors;
698 my_current_count = 0;
700 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
701 my_built_predecessors.clear();
718 #if __TBB_PREVIEW_MESSAGE_BASED_KEY_MATCHING
719 template <
typename K,
typename T>
736 namespace interface11 {
741 #if __TBB_PREVIEW_ASYNC_MSG
744 using namespace internal::graph_policy_namespace;
746 template <
typename C,
typename N>
749 if (begin) current_node = my_graph->my_nodes;
753 template <
typename C,
typename N>
756 return *operator->();
759 template <
typename C,
typename N>
764 template <
typename C,
typename N>
766 if (current_node) current_node = current_node->next;
771 namespace interface10 {
773 inline graph::graph() : my_nodes(NULL), my_nodes_last(NULL), my_task_arena(NULL) {
786 my_context(&use_this_context), my_nodes(NULL), my_nodes_last(NULL), my_task_arena(NULL) {
787 prepare_task_arena();
790 caught_exception =
false;
792 my_root_task->set_ref_count(1);
877 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
878 inline void graph::set_name(
const char *
name) {
885 namespace interface11 {
888 my_graph.register_node(
this);
892 my_graph.remove_node(
this);
897 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
898 using internal::node_set;
902 template <
typename Output >
914 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
920 template<
typename Body >
925 my_reserved(false), my_has_cached_item(false)
927 my_successors.set_owner(
this);
932 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
933 template <
typename Body,
typename... Successors>
934 input_node(
const node_set<internal::order::preceding, Successors...>& successors, Body body )
935 : input_node(successors.graph_reference(), body) {
936 make_edges(*
this, successors);
944 my_body( src.my_init_body->clone() ), my_init_body(src.my_init_body->clone() ),
945 my_reserved(false), my_has_cached_item(false)
947 my_successors.set_owner(
this);
955 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
964 my_successors.register_successor(r);
973 my_successors.remove_successor(r);
977 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
979 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
981 void internal_add_built_successor( successor_type &r)
__TBB_override {
983 my_successors.internal_add_built_successor(r);
986 void internal_delete_built_successor( successor_type &r)
__TBB_override {
988 my_successors.internal_delete_built_successor(r);
993 return my_successors.successor_count();
998 my_successors.copy_successors(v);
1008 if ( my_has_cached_item ) {
1010 my_has_cached_item =
false;
1023 if ( my_reserved ) {
1027 if ( my_has_cached_item ) {
1040 __TBB_ASSERT( my_reserved && my_has_cached_item,
"releasing non-existent reservation" );
1041 my_reserved =
false;
1042 if(!my_successors.empty())
1050 __TBB_ASSERT( my_reserved && my_has_cached_item,
"consuming non-existent reservation" );
1051 my_reserved =
false;
1052 my_has_cached_item =
false;
1053 if ( !my_successors.empty() ) {
1063 if (!my_successors.empty())
1067 template<
typename Body>
1073 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1075 my_successors.built_successors().sender_extract(*
this);
1077 my_reserved =
false;
1078 if(my_has_cached_item) my_has_cached_item =
false;
1087 my_reserved =
false;
1088 my_has_cached_item =
false;
1111 if ( my_reserved ) {
1114 if ( !my_has_cached_item ) {
1116 bool r = (*my_body)(my_cached_item);
1119 my_has_cached_item =
true;
1122 if ( my_has_cached_item ) {
1132 return (
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
1147 if ( !try_reserve_apply_body(v) )
1150 task *last_task = my_successors.try_put_task(v);
1159 #if TBB_USE_SOURCE_NODE_AS_ALIAS
1160 template <
typename Output >
1161 class source_node :
public input_node <Output> {
1164 template<
typename Body >
1166 : input_node<Output>(g, body)
1170 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1171 template <
typename Body,
typename... Successors>
1172 source_node(
const node_set<internal::order::preceding, Successors...>& successors, Body body )
1173 : input_node<Output>(successors, body) {
1177 #else // TBB_USE_SOURCE_NODE_AS_ALIAS
1178 template <
typename Output >
class
1180 __TBB_DEPRECATED_MSG(
"TBB Warning: tbb::flow::source_node is deprecated, use tbb::flow::input_node." )
1192 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1198 template<
typename Body >
1200 : graph_node(g), my_active(is_active), init_my_active(is_active),
1201 my_body( new internal::source_body_leaf< output_type, Body>(body) ),
1202 my_init_body( new internal::source_body_leaf< output_type, Body>(body) ),
1203 my_reserved(false), my_has_cached_item(false)
1205 my_successors.set_owner(
this);
1210 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1211 template <
typename Body,
typename... Successors>
1212 source_node(
const node_set<internal::order::preceding, Successors...>& successors, Body body,
bool is_active =
true )
1214 make_edges(*
this, successors);
1220 graph_node(src.my_graph),
sender<Output>(),
1221 my_active(src.init_my_active),
1222 init_my_active(src.init_my_active), my_body( src.my_init_body->clone() ), my_init_body(src.my_init_body->clone() ),
1223 my_reserved(false), my_has_cached_item(false)
1225 my_successors.set_owner(
this);
1233 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1242 my_successors.register_successor(r);
1251 my_successors.remove_successor(r);
1255 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1257 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
1261 my_successors.internal_add_built_successor(r);
1264 void internal_delete_built_successor( successor_type &r)
__TBB_override {
1266 my_successors.internal_delete_built_successor(r);
1271 return my_successors.successor_count();
1276 my_successors.copy_successors(v);
1286 if ( my_has_cached_item ) {
1288 my_has_cached_item =
false;
1300 if ( my_reserved ) {
1304 if ( my_has_cached_item ) {
1317 __TBB_ASSERT( my_reserved && my_has_cached_item,
"releasing non-existent reservation" );
1318 my_reserved =
false;
1319 if(!my_successors.empty())
1327 __TBB_ASSERT( my_reserved && my_has_cached_item,
"consuming non-existent reservation" );
1328 my_reserved =
false;
1329 my_has_cached_item =
false;
1330 if ( !my_successors.empty() ) {
1340 if (!my_successors.empty())
1344 template<
typename Body>
1350 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1352 my_successors.built_successors().sender_extract(*
this);
1353 my_active = init_my_active;
1354 my_reserved =
false;
1355 if(my_has_cached_item) my_has_cached_item =
false;
1363 my_active = init_my_active;
1365 if(my_has_cached_item) {
1366 my_has_cached_item =
false;
1368 if(f & rf_clear_edges) my_successors.clear();
1392 if ( my_reserved ) {
1395 if ( !my_has_cached_item ) {
1397 bool r = (*my_body)(my_cached_item);
1400 my_has_cached_item =
true;
1403 if ( my_has_cached_item ) {
1417 return (
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
1432 if ( !try_reserve_apply_body(v) )
1443 #endif // TBB_USE_SOURCE_NODE_AS_ALIAS
1446 template<
typename Input,
typename Output = continue_msg,
typename Policy =
queueing,
1450 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
1457 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
1464 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
1465 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
1477 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1478 typedef typename input_impl_type::predecessor_list_type predecessor_list_type;
1479 typedef typename fOutput_type::successor_list_type successor_list_type;
1481 using input_impl_type::my_predecessors;
1487 template<
typename Body >
1500 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1501 template <
typename Body>
1504 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1506 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1507 template <
typename Body,
typename... Args>
1511 make_edges_in_order(nodes, *
this);
1514 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1515 template <
typename Body,
typename... Args>
1518 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1519 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1523 graph_node(src.my_graph),
1524 input_impl_type(src),
1525 fOutput_type(src.my_graph) {
1530 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1536 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1538 my_predecessors.built_predecessors().receiver_extract(*
this);
1539 successors().built_successors().sender_extract(*
this);
1547 using input_impl_type::try_put_task;
1552 input_impl_type::reset_function_input(f);
1554 if(f & rf_clear_edges) {
1555 successors().clear();
1556 my_predecessors.clear();
1558 __TBB_ASSERT(!(f & rf_clear_edges) || successors().
empty(),
"function_node successors not empty");
1559 __TBB_ASSERT(this->my_predecessors.empty(),
"function_node predecessors not empty");
1566 template<
typename Input,
typename Output,
typename Policy =
queueing,
1573 typename internal::wrap_tuple_elements<
1574 tbb::flow::tuple_size<Output>::value,
1575 internal::multifunction_output,
1579 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
1582 cache_aligned_allocator<Input>
1585 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
1586 typedef Allocator internals_allocator;
1592 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
1593 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
1607 using input_impl_type::my_predecessors;
1609 template<
typename Body>
1611 graph &g,
size_t concurrency,
1618 tbb::internal::fgt_multioutput_node_with_body<N>(
1619 CODEPTR(), tbb::internal::FLOW_MULTIFUNCTION_NODE,
1621 this->output_ports(), this->my_body
1625 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1626 template <
typename Body>
1628 : multifunction_node(g, concurrency, body,
Policy(), priority) {}
1629 #endif // TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1631 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1632 template <
typename Body,
typename... Args>
1633 __TBB_NOINLINE_SYM multifunction_node(
const node_set<Args...>& nodes,
size_t concurrency, Body body,
1636 make_edges_in_order(nodes, *
this);
1639 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1640 template <
typename Body,
typename... Args>
1642 : multifunction_node(nodes, concurrency, body,
Policy(), priority) {}
1643 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1644 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1647 graph_node(other.my_graph), input_impl_type(other) {
1648 tbb::internal::fgt_multioutput_node_with_body<N>(
CODEPTR(), tbb::internal::FLOW_MULTIFUNCTION_NODE,
1650 this->output_ports(), this->my_body );
1653 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1659 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1661 my_predecessors.built_predecessors().receiver_extract(*
this);
1662 input_impl_type::extract();
1672 template<
typename TupleType,
typename Allocator=__TBB_DEFAULT_NODE_ALLOCATOR(TupleType)>
1678 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
1683 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
1684 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
1687 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1688 typedef typename base_type::predecessor_type predecessor_type;
1689 typedef typename base_type::predecessor_list_type predecessor_list_type;
1691 typedef typename predecessor_cache_type::built_predecessors_type built_predecessors_type;
1704 tbb::internal::fgt_multioutput_node<N>(
CODEPTR(), tbb::internal::FLOW_SPLIT_NODE, &this->my_graph,
1708 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1709 template <
typename... Args>
1711 make_edges_in_order(nodes, *
this);
1717 my_output_ports(internal::
init_output_ports<output_ports_type>::
call(other.my_graph, my_output_ports))
1719 tbb::internal::fgt_multioutput_node<N>(
CODEPTR(), tbb::internal::FLOW_SPLIT_NODE, &this->my_graph,
1723 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1738 if (f & rf_clear_edges)
1747 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1761 built_predecessors_type &built_predecessors()
__TBB_override {
return my_predessors; }
1764 built_predecessors_type my_predessors;
1772 template <
typename Output,
typename Policy =
internal::Policy<
void> >
1784 template <
typename Body >
1800 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1801 template <
typename Body>
1806 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1807 template <
typename Body,
typename... Args>
1811 make_edges_in_order(nodes, *
this);
1813 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1814 template <
typename Body,
typename... Args>
1817 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1818 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1821 template <
typename Body >
1837 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
1838 template <
typename Body>
1843 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1844 template <
typename Body,
typename... Args>
1848 make_edges_in_order(nodes, *
this);
1851 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
1852 template <
typename Body,
typename... Args>
1853 continue_node(
const node_set<Args...>& nodes,
int number_of_predecessors,
1855 : continue_node(nodes, number_of_predecessors, body,
Policy(), priority) {}
1862 internal::function_output<Output>(src.my_graph) {
1868 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1874 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1876 input_impl_type::my_built_predecessors.receiver_extract(*
this);
1877 successors().built_successors().sender_extract(*
this);
1885 using input_impl_type::try_put_task;
1889 input_impl_type::reset_receiver(f);
1890 if(f & rf_clear_edges)successors().clear();
1891 __TBB_ASSERT(!(f & rf_clear_edges) || successors().
empty(),
"continue_node not reset");
1896 template <
typename T>
1903 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1909 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1910 internal::edge_container<predecessor_type> my_built_predecessors;
1921 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
1922 template <
typename... Args>
1923 broadcast_node(
const node_set<Args...>& nodes) : broadcast_node(nodes.graph_reference()) {
1924 make_edges_in_order(nodes, *
this);
1937 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
1955 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1958 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
1960 void internal_add_built_successor(successor_type &r)
__TBB_override {
1961 my_successors.internal_add_built_successor(r);
1964 void internal_delete_built_successor(successor_type &r)
__TBB_override {
1965 my_successors.internal_delete_built_successor(r);
1969 return my_successors.successor_count();
1973 my_successors.copy_successors(v);
1978 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
1980 void internal_add_built_predecessor( predecessor_type &p)
__TBB_override {
1982 my_built_predecessors.add_edge(p);
1985 void internal_delete_built_predecessor( predecessor_type &p)
__TBB_override {
1987 my_built_predecessors.delete_edge(p);
1992 return my_built_predecessors.edge_count();
1995 void copy_predecessors(predecessor_list_type &v)
__TBB_override {
1997 my_built_predecessors.copy_edges(v);
2001 my_built_predecessors.receiver_extract(*
this);
2002 my_successors.built_successors().sender_extract(*
this);
2024 if (f&rf_clear_edges) {
2025 my_successors.
clear();
2026 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2027 my_built_predecessors.clear();
2030 __TBB_ASSERT(!(f & rf_clear_edges) || my_successors.
empty(),
"Error resetting broadcast_node");
2035 template <
typename T,
typename Allocator=__TBB_DEFAULT_NODE_ALLOCATOR(T) >
2038 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2044 #if TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2055 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2059 #if !TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2062 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
2063 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
2071 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2072 internal::edge_container<predecessor_type> my_built_predecessors;
2077 enum op_type {reg_succ, rem_succ, req_item, res_item, rel_res, con_res, put_item, try_fwd_task
2078 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2079 , add_blt_succ, del_blt_succ,
2080 add_blt_pred, del_blt_pred,
2081 blt_succ_cnt, blt_pred_cnt,
2082 blt_succ_cpy, blt_pred_cpy
2090 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2097 successor_list_type *svec;
2098 predecessor_list_type *pvec;
2107 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2108 , ltask(NULL), elem(const_cast<T*>(&e))
2110 , elem(const_cast<T*>(&e)) , ltask(NULL)
2117 typedef internal::aggregating_functor<class_type, buffer_operation>
handler_type;
2122 handle_operations_impl(op_list,
this);
2125 template<
typename derived_type>
2127 __TBB_ASSERT(static_cast<class_type*>(derived) ==
this,
"'this' is not a base class for derived");
2130 bool try_forwarding =
false;
2133 op_list = op_list->next;
2134 switch (tmp->
type) {
2135 case reg_succ: internal_reg_succ(tmp); try_forwarding =
true;
break;
2136 case rem_succ: internal_rem_succ(tmp);
break;
2137 case req_item: internal_pop(tmp);
break;
2138 case res_item: internal_reserve(tmp);
break;
2139 case rel_res: internal_release(tmp); try_forwarding =
true;
break;
2140 case con_res: internal_consume(tmp); try_forwarding =
true;
break;
2141 case put_item: try_forwarding = internal_push(tmp);
break;
2142 case try_fwd_task: internal_forward_task(tmp);
break;
2143 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2145 case add_blt_succ: internal_add_built_succ(tmp);
break;
2146 case del_blt_succ: internal_del_built_succ(tmp);
break;
2147 case add_blt_pred: internal_add_built_pred(tmp);
break;
2148 case del_blt_pred: internal_del_built_pred(tmp);
break;
2149 case blt_succ_cnt: internal_succ_cnt(tmp);
break;
2150 case blt_pred_cnt: internal_pred_cnt(tmp);
break;
2151 case blt_succ_cpy: internal_copy_succs(tmp);
break;
2152 case blt_pred_cpy: internal_copy_preds(tmp);
break;
2159 if (try_forwarding && !forwarder_busy) {
2161 forwarder_busy =
true;
2162 task *new_task =
new(task::allocate_additional_child_of(*(this->my_graph.root_task())))
internal::
2163 forward_task_bypass<class_type>(*
this);
2168 graph &g = this->my_graph;
2175 return op_data.
ltask;
2179 task *ft = grab_forwarding_task(op_data);
2190 task *last_task = NULL;
2193 op_data.
ltask = NULL;
2194 my_aggregator.
execute(&op_data);
2198 graph& g = this->my_graph;
2216 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2219 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
2221 virtual void internal_add_built_succ(buffer_operation *op) {
2222 my_successors.internal_add_built_successor(*(op->r));
2226 virtual void internal_del_built_succ(buffer_operation *op) {
2227 my_successors.internal_delete_built_successor(*(op->r));
2231 typedef typename receiver<T>::built_predecessors_type built_predecessors_type;
2233 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
2235 virtual void internal_add_built_pred(buffer_operation *op) {
2236 my_built_predecessors.add_edge(*(op->p));
2240 virtual void internal_del_built_pred(buffer_operation *op) {
2241 my_built_predecessors.delete_edge(*(op->p));
2245 virtual void internal_succ_cnt(buffer_operation *op) {
2246 op->cnt_val = my_successors.successor_count();
2250 virtual void internal_pred_cnt(buffer_operation *op) {
2251 op->cnt_val = my_built_predecessors.edge_count();
2255 virtual void internal_copy_succs(buffer_operation *op) {
2256 my_successors.copy_successors(*(op->svec));
2260 virtual void internal_copy_preds(buffer_operation *op) {
2261 my_built_predecessors.copy_edges(*(op->pvec));
2271 return this->my_item_valid(this->my_tail - 1);
2278 graph& g = this->my_graph;
2280 this->destroy_back();
2287 internal_forward_task_impl(op,
this);
2290 template<
typename derived_type>
2292 __TBB_ASSERT(static_cast<class_type*>(derived) ==
this,
"'this' is not a base class for derived");
2294 if (this->my_reserved || !derived->is_item_valid()) {
2296 this->forwarder_busy =
false;
2300 task * last_task = NULL;
2301 size_type counter = my_successors.size();
2302 for (; counter > 0 && derived->is_item_valid(); --counter)
2303 derived->try_put_and_add_task(last_task);
2305 op->
ltask = last_task;
2306 if (last_task && !counter) {
2311 forwarder_busy =
false;
2316 this->push_back(*(op->
elem));
2322 if(this->pop_back(*(op->
elem))) {
2331 if(this->reserve_front(*(op->
elem))) {
2340 this->consume_front();
2345 this->release_front();
2353 sender<T>(), forwarder_busy(false)
2361 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
2362 template <
typename... Args>
2363 buffer_node(
const node_set<Args...>& nodes) : buffer_node(nodes.graph_reference()) {
2364 make_edges_in_order(nodes, *
this);
2379 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
2394 my_aggregator.execute(&op_data);
2395 (
void)enqueue_forwarding_task(op_data);
2399 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2400 void internal_add_built_successor( successor_type &r)
__TBB_override {
2401 buffer_operation op_data(add_blt_succ);
2403 my_aggregator.execute(&op_data);
2406 void internal_delete_built_successor( successor_type &r)
__TBB_override {
2407 buffer_operation op_data(del_blt_succ);
2409 my_aggregator.execute(&op_data);
2412 void internal_add_built_predecessor( predecessor_type &p)
__TBB_override {
2413 buffer_operation op_data(add_blt_pred);
2415 my_aggregator.execute(&op_data);
2418 void internal_delete_built_predecessor( predecessor_type &p)
__TBB_override {
2419 buffer_operation op_data(del_blt_pred);
2421 my_aggregator.execute(&op_data);
2425 buffer_operation op_data(blt_pred_cnt);
2426 my_aggregator.execute(&op_data);
2427 return op_data.cnt_val;
2431 buffer_operation op_data(blt_succ_cnt);
2432 my_aggregator.execute(&op_data);
2433 return op_data.cnt_val;
2436 void copy_predecessors( predecessor_list_type &v )
__TBB_override {
2437 buffer_operation op_data(blt_pred_cpy);
2439 my_aggregator.execute(&op_data);
2443 buffer_operation op_data(blt_succ_cpy);
2445 my_aggregator.execute(&op_data);
2454 r.remove_predecessor(*
this);
2457 my_aggregator.execute(&op_data);
2461 (
void)enqueue_forwarding_task(op_data);
2471 my_aggregator.execute(&op_data);
2472 (
void)enqueue_forwarding_task(op_data);
2482 my_aggregator.execute(&op_data);
2483 (
void)enqueue_forwarding_task(op_data);
2491 my_aggregator.execute(&op_data);
2492 (
void)enqueue_forwarding_task(op_data);
2500 my_aggregator.execute(&op_data);
2501 (
void)enqueue_forwarding_task(op_data);
2513 my_aggregator.execute(&op_data);
2514 task *ft = grab_forwarding_task(op_data);
2536 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2539 my_built_predecessors.receiver_extract(*
this);
2540 my_successors.built_successors().sender_extract(*
this);
2548 if (f&rf_clear_edges) {
2549 my_successors.
clear();
2550 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
2551 my_built_predecessors.clear();
2554 forwarder_busy =
false;
2559 template <
typename T,
typename Allocator=__TBB_DEFAULT_NODE_ALLOCATOR(T) >
2561 #if !TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2564 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
2565 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
2578 return this->my_item_valid(this->my_head);
2585 graph& graph_ref = this->graph_reference();
2587 this->destroy_front();
2593 this->internal_forward_task_impl(op,
this);
2597 if ( this->my_reserved || !this->my_item_valid(this->my_head)){
2601 this->pop_front(*(op->elem));
2606 if (this->my_reserved || !this->my_item_valid(this->my_head)) {
2610 this->reserve_front(*(op->elem));
2615 this->consume_front();
2632 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
2633 template <
typename... Args>
2634 queue_node(
const node_set<Args...>& nodes) : queue_node(nodes.graph_reference()) {
2635 make_edges_in_order(nodes, *
this);
2646 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
2654 base_type::reset_node(f);
2659 template<
typename T,
typename Allocator=__TBB_DEFAULT_NODE_ALLOCATOR(T) >
2665 #if !TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2668 "Allocator template parameter for flow graph nodes is deprecated and will be removed. "
2669 "Specify TBB_DEPRECATED_FLOW_NODE_ALLOCATOR to temporary enable the deprecated interface."
2678 template<
typename Sequencer >
2680 my_sequencer(new internal::function_body_leaf< T, size_t, Sequencer>(s) ) {
2686 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
2687 template <
typename Sequencer,
typename... Args>
2688 sequencer_node(
const node_set<Args...>& nodes,
const Sequencer& s)
2689 : sequencer_node(nodes.graph_reference(), s) {
2690 make_edges_in_order(nodes, *
this);
2696 my_sequencer( src.my_sequencer->clone() ) {
2705 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
2717 size_type tag = (*my_sequencer)(*(op->elem));
2718 #if !TBB_DEPRECATED_SEQUENCER_DUPLICATES
2719 if (tag < this->my_head) {
2726 size_t new_tail = (tag+1 > this->my_tail) ? tag+1 : this->my_tail;
2728 if (this->
size(new_tail) > this->capacity()) {
2729 this->grow_my_array(this->
size(new_tail));
2731 this->my_tail = new_tail;
2740 template<
typename T,
typename Compare = std::less<T>,
typename Allocator=__TBB_DEFAULT_NODE_ALLOCATOR(T)>
2743 #if !TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
2746 "Allocator template parameter for flow graph nodes is deprecated and will removed in the future. "
2747 "To temporary enable the deprecated interface specify TBB_ENABLE_DEPRECATED_NODE_ALLOCATOR."
2759 :
buffer_node<T, Allocator>(g), compare(comp), mark(0) {
2765 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
2766 template <
typename... Args>
2768 : priority_queue_node(nodes.graph_reference(), comp) {
2769 make_edges_in_order(nodes, *
this);
2782 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
2792 base_type::reset_node(f);
2801 this->internal_forward_task_impl(op,
this);
2805 this->handle_operations_impl(op_list,
this);
2809 prio_push(*(op->elem));
2816 if ( this->my_reserved ==
true || this->my_tail == 0 ) {
2821 *(op->elem) = prio();
2829 if (this->my_reserved ==
true || this->my_tail == 0) {
2833 this->my_reserved =
true;
2834 *(op->elem) = prio();
2835 reserved_item = *(op->elem);
2842 this->my_reserved =
false;
2843 reserved_item = input_type();
2848 prio_push(reserved_item);
2849 this->my_reserved =
false;
2850 reserved_item = input_type();
2857 if (mark < this->my_tail) heapify();
2858 __TBB_ASSERT(mark == this->my_tail,
"mark unequal after heapify");
2862 return this->my_tail > 0;
2869 graph& graph_ref = this->graph_reference();
2883 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds before test");
2884 return mark < this->my_tail && compare(this->get_my_item(0), this->get_my_item(this->my_tail - 1));
2889 if ( this->my_tail >= this->my_array_size )
2890 this->grow_my_array( this->my_tail + 1 );
2891 (
void) this->place_item(this->my_tail, src);
2893 __TBB_ASSERT(mark < this->my_tail,
"mark outside bounds after push");
2900 if (prio_use_tail()) {
2903 this->destroy_item(this->my_tail-1);
2905 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds after pop");
2908 this->destroy_item(0);
2909 if(this->my_tail > 1) {
2911 __TBB_ASSERT(this->my_item_valid(this->my_tail - 1), NULL);
2912 this->move_item(0,this->my_tail - 1);
2915 if(mark > this->my_tail) --mark;
2916 if (this->my_tail > 1)
2918 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds after pop");
2922 return this->get_my_item(prio_use_tail() ? this->my_tail-1 : 0);
2927 if(this->my_tail == 0) {
2931 if (!mark) mark = 1;
2932 for (; mark<this->my_tail; ++mark) {
2934 input_type to_place;
2935 this->fetch_item(mark,to_place);
2938 if (!compare(this->get_my_item(parent), to_place))
2940 this->move_item(cur_pos, parent);
2943 (
void) this->place_item(cur_pos, to_place);
2950 while (child < mark) {
2953 compare(this->get_my_item(child),
2954 this->get_my_item(child+1)))
2957 if (compare(this->get_my_item(target),
2958 this->get_my_item(cur_pos)))
2961 this->swap_items(cur_pos, target);
2963 child = (cur_pos<<1)+1;
2970 namespace interface11 {
2976 template<
typename T,
typename DecrementType=continue_msg >
2977 class limiter_node :
public graph_node,
public receiver< T >,
public sender< T > {
2983 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
3006 return ( my_count + my_tries < my_threshold && !my_predecessors.empty() && !my_successors.
empty() );
3013 bool reserved =
false;
3016 if ( check_conditions() )
3025 if ( (my_predecessors.try_reserve(v)) ==
true ){
3032 my_predecessors.try_consume();
3033 if ( check_conditions() ) {
3035 task *rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
3050 if (reserved) my_predecessors.try_release();
3051 if ( check_conditions() ) {
3053 task *rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
3071 if( delta > 0 &&
size_t(delta) > my_count )
3073 else if( delta < 0 &&
size_t(delta) > my_threshold - my_count )
3074 my_count = my_threshold;
3076 my_count -= size_t(delta);
3078 return forward_task();
3082 my_predecessors.set_owner(
this);
3084 decrement.set_owner(
this);
3086 CODEPTR(), tbb::internal::FLOW_LIMITER_NODE, &this->my_graph,
3095 #if TBB_DEPRECATED_LIMITER_NODE_CONSTRUCTOR
3097 "Deprecated interface of the limiter node can be used only in conjunction "
3098 "with continue_msg as the type of DecrementType template parameter." );
3099 #endif // Check for incompatible interface
3104 : graph_node(g), my_threshold(threshold), my_count(0),
3106 my_tries(0), decrement(),
3107 init_decrement_predecessors(num_decrement_predecessors),
3108 decrement(num_decrement_predecessors)) {
3112 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3113 template <
typename... Args>
3114 limiter_node(
const node_set<Args...>& nodes,
size_t threshold)
3115 : limiter_node(nodes.graph_reference(), threshold) {
3116 make_edges_in_order(nodes, *
this);
3123 my_threshold(src.my_threshold), my_count(0),
3125 my_tries(0), decrement(),
3126 init_decrement_predecessors(src.init_decrement_predecessors),
3127 decrement(src.init_decrement_predecessors)) {
3131 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3140 bool was_empty = my_successors.
empty();
3143 if ( was_empty && !my_predecessors.empty() && my_count + my_tries < my_threshold ) {
3145 task*
task =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
3156 r.remove_predecessor(*
this);
3161 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
3162 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
3163 built_predecessors_type &built_predecessors()
__TBB_override {
return my_predecessors.built_predecessors(); }
3165 void internal_add_built_successor(successor_type &src)
__TBB_override {
3166 my_successors.internal_add_built_successor(src);
3169 void internal_delete_built_successor(successor_type &src)
__TBB_override {
3170 my_successors.internal_delete_built_successor(src);
3173 size_t successor_count()
__TBB_override {
return my_successors.successor_count(); }
3176 my_successors.copy_successors(v);
3179 void internal_add_built_predecessor(predecessor_type &src)
__TBB_override {
3180 my_predecessors.internal_add_built_predecessor(src);
3183 void internal_delete_built_predecessor(predecessor_type &src)
__TBB_override {
3184 my_predecessors.internal_delete_built_predecessor(src);
3187 size_t predecessor_count()
__TBB_override {
return my_predecessors.predecessor_count(); }
3189 void copy_predecessors(predecessor_list_type &v)
__TBB_override {
3190 my_predecessors.copy_predecessors(v);
3195 my_successors.built_successors().sender_extract(*
this);
3196 my_predecessors.built_predecessors().receiver_extract(*
this);
3197 decrement.built_predecessors().receiver_extract(decrement);
3204 my_predecessors.add( src );
3206 task*
task =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
3215 my_predecessors.remove( src );
3228 if ( my_count + my_tries >= my_threshold )
3240 rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
3260 if(f & rf_clear_edges) {
3261 my_predecessors.clear();
3262 my_successors.
clear();
3266 my_predecessors.reset( );
3268 decrement.reset_receiver(f);
3280 template<
typename OutputTuple,
typename JP=queueing>
class join_node;
3282 template<
typename OutputTuple>
3291 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_RESERVING, &this->my_graph,
3295 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3296 template <
typename... Args>
3298 make_edges_in_order(nodes, *
this);
3303 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_RESERVING, &this->my_graph,
3307 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3315 template<
typename OutputTuple>
3324 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_QUEUEING, &this->my_graph,
3328 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3329 template <
typename... Args>
3331 make_edges_in_order(nodes, *
this);
3336 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_QUEUEING, &this->my_graph,
3340 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3350 template<
typename OutputTuple,
typename K,
typename KHash>
3352 key_matching_port, OutputTuple, key_matching<K,KHash> > {
3360 #if __TBB_PREVIEW_MESSAGE_BASED_KEY_MATCHING
3363 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3364 template <
typename... Args>
3366 : join_node(nodes.graph_reference()) {
3367 make_edges_in_order(nodes, *
this);
3373 template<
typename __TBB_B0,
typename __TBB_B1>
3375 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3378 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2>
3380 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3383 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3>
3385 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3388 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4>
3391 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3394 #if __TBB_VARIADIC_MAX >= 6
3395 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
3399 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3403 #if __TBB_VARIADIC_MAX >= 7
3404 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
3405 typename __TBB_B5,
typename __TBB_B6>
3408 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3412 #if __TBB_VARIADIC_MAX >= 8
3413 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
3414 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7>
3416 __TBB_B7 b7) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7) {
3417 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3421 #if __TBB_VARIADIC_MAX >= 9
3422 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
3423 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7,
typename __TBB_B8>
3425 __TBB_B7 b7, __TBB_B8 b8) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8) {
3426 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3430 #if __TBB_VARIADIC_MAX >= 10
3431 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
3432 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7,
typename __TBB_B8,
typename __TBB_B9>
3434 __TBB_B7 b7, __TBB_B8 b8, __TBB_B9 b9) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) {
3435 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3440 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3441 template <
typename... Args,
typename... Bodies>
3443 : join_node(nodes.graph_reference(), bodies...) {
3444 make_edges_in_order(nodes, *
this);
3449 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
3453 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3465 template<
typename T0,
typename T1=null_type,
typename T2=null_type,
typename T3=null_type,
3466 typename T4=null_type,
typename T5=null_type,
typename T6=null_type,
3470 template<
typename T0>
3473 static const int N = 1;
3479 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3483 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3484 template <
typename... Args>
3485 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3486 make_edges_in_order(nodes, *
this);
3492 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3496 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3503 template<
typename T0,
typename T1>
3506 static const int N = 2;
3512 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3516 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3517 template <
typename... Args>
3518 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3519 make_edges_in_order(nodes, *
this);
3525 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3529 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3536 template<
typename T0,
typename T1,
typename T2>
3539 static const int N = 3;
3545 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3549 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3550 template <
typename... Args>
3551 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3552 make_edges_in_order(nodes, *
this);
3558 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3562 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3569 template<
typename T0,
typename T1,
typename T2,
typename T3>
3572 static const int N = 4;
3578 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3582 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3583 template <
typename... Args>
3584 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3585 make_edges_in_order(nodes, *
this);
3591 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3595 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3602 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
3605 static const int N = 5;
3611 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3615 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3616 template <
typename... Args>
3617 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3618 make_edges_in_order(nodes, *
this);
3624 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3628 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3635 #if __TBB_VARIADIC_MAX >= 6
3636 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
3637 class indexer_node<T0, T1, T2, T3, T4, T5> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5> > {
3639 static const int N = 6;
3645 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3649 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3650 template <
typename... Args>
3651 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3652 make_edges_in_order(nodes, *
this);
3658 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3662 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3668 #endif //variadic max 6
3670 #if __TBB_VARIADIC_MAX >= 7
3671 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3673 class indexer_node<T0, T1, T2, T3, T4, T5, T6> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5, T6> > {
3675 static const int N = 7;
3681 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3685 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3686 template <
typename... Args>
3687 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3688 make_edges_in_order(nodes, *
this);
3694 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3698 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3704 #endif //variadic max 7
3706 #if __TBB_VARIADIC_MAX >= 8
3707 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3708 typename T6,
typename T7>
3709 class indexer_node<T0, T1, T2, T3, T4, T5, T6, T7> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5, T6, T7> > {
3711 static const int N = 8;
3717 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3721 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3722 template <
typename... Args>
3723 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3724 make_edges_in_order(nodes, *
this);
3730 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3734 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3740 #endif //variadic max 8
3742 #if __TBB_VARIADIC_MAX >= 9
3743 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3744 typename T6,
typename T7,
typename T8>
3745 class indexer_node<T0, T1, T2, T3, T4, T5, T6, T7, T8> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> > {
3747 static const int N = 9;
3753 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3757 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3758 template <
typename... Args>
3759 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3760 make_edges_in_order(nodes, *
this);
3766 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3770 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3776 #endif //variadic max 9
3778 #if __TBB_VARIADIC_MAX >= 10
3779 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3780 typename T6,
typename T7,
typename T8,
typename T9>
3783 static const int N = 10;
3785 typedef tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
InputTuple;
3786 typedef typename internal::tagged_msg<size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> output_type;
3789 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3793 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
3794 template <
typename... Args>
3795 indexer_node(
const node_set<Args...>& nodes) : indexer_node(nodes.graph_reference()) {
3796 make_edges_in_order(nodes, *
this);
3802 tbb::internal::fgt_multiinput_node<N>(
CODEPTR(), tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3806 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3812 #endif //variadic max 10
3814 #if __TBB_PREVIEW_ASYNC_MSG
3817 template<
typename T >
3820 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
3821 s.internal_add_built_predecessor(p);
3822 p.internal_add_built_successor(s);
3829 template<
typename T >
3834 #if __TBB_PREVIEW_ASYNC_MSG
3835 template<
typename TS,
typename TR,
3842 template<
typename T >
3847 template<
typename T >
3852 #endif // __TBB_PREVIEW_ASYNC_MSG
3854 #if __TBB_FLOW_GRAPH_CPP11_FEATURES
3856 template<
typename T,
typename V,
3857 typename =
typename T::output_ports_type,
typename =
typename V::input_ports_type >
3859 make_edge(get<0>(output.output_ports()), get<0>(input.input_ports()));
3863 template<
typename T,
typename R,
3864 typename =
typename T::output_ports_type >
3866 make_edge(get<0>(output.output_ports()), input);
3870 template<
typename S,
typename V,
3871 typename =
typename V::input_ports_type >
3873 make_edge(output, get<0>(input.input_ports()));
3877 #if __TBB_PREVIEW_ASYNC_MSG
3880 template<
typename T >
3884 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
3886 p.internal_delete_built_successor(s);
3887 s.internal_delete_built_predecessor(p);
3893 template<
typename T >
3898 #if __TBB_PREVIEW_ASYNC_MSG
3899 template<
typename TS,
typename TR,
3906 template<
typename T >
3911 template<
typename T >
3915 #endif // __TBB_PREVIEW_ASYNC_MSG
3917 #if __TBB_FLOW_GRAPH_CPP11_FEATURES
3919 template<
typename T,
typename V,
3920 typename =
typename T::output_ports_type,
typename =
typename V::input_ports_type >
3922 remove_edge(get<0>(output.output_ports()), get<0>(input.input_ports()));
3926 template<
typename T,
typename R,
3927 typename =
typename T::output_ports_type >
3929 remove_edge(get<0>(output.output_ports()), input);
3932 template<
typename S,
typename V,
3933 typename =
typename V::input_ports_type >
3939 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
3940 template<
typename C >
3941 template<
typename S >
3942 void internal::edge_container<C>::sender_extract(
S &s ) {
3943 edge_list_type e = built_edges;
3944 for (
typename edge_list_type::iterator i = e.begin(); i != e.end(); ++i ) {
3949 template<
typename C >
3950 template<
typename R >
3951 void internal::edge_container<C>::receiver_extract( R &r ) {
3952 edge_list_type e = built_edges;
3953 for (
typename edge_list_type::iterator i = e.begin(); i != e.end(); ++i ) {
3960 template<
typename Body,
typename Node >
3962 return n.template copy_function_object<Body>();
3965 #if __TBB_FLOW_GRAPH_CPP11_FEATURES
3970 template<
typename... InputTypes,
typename... OutputTypes>
3971 class composite_node <tbb::flow::tuple<InputTypes...>, tbb::flow::tuple<OutputTypes...> > :
public graph_node{
3981 static const size_t NUM_INPUTS =
sizeof...(InputTypes);
3982 static const size_t NUM_OUTPUTS =
sizeof...(OutputTypes);
3988 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
3999 template<
typename T1,
typename T2>
4003 my_input_ports = tbb::internal::make_unique<input_ports_type>(std::forward<T1>(input_ports_tuple));
4004 my_output_ports = tbb::internal::make_unique<output_ports_type>(std::forward<T2>(output_ports_tuple));
4010 template<
typename... NodeTypes >
4013 template<
typename... NodeTypes >
4016 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4023 __TBB_ASSERT(my_input_ports,
"input ports not set, call set_external_ports to set input ports");
4024 return *my_input_ports;
4028 __TBB_ASSERT(my_output_ports,
"output ports not set, call set_external_ports to set output ports");
4029 return *my_output_ports;
4032 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4034 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
4040 template<
typename... InputTypes>
4041 class composite_node <tbb::flow::tuple<InputTypes...>, tbb::flow::tuple<> > :
public graph_node {
4047 static const size_t NUM_INPUTS =
sizeof...(InputTypes);
4053 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4064 template<
typename T>
4068 my_input_ports = tbb::internal::make_unique<input_ports_type>(std::forward<T>(input_ports_tuple));
4073 template<
typename... NodeTypes >
4076 template<
typename... NodeTypes >
4079 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4086 __TBB_ASSERT(my_input_ports,
"input ports not set, call set_external_ports to set input ports");
4087 return *my_input_ports;
4090 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4092 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
4099 template<
typename... OutputTypes>
4100 class composite_node <tbb::flow::tuple<>, tbb::flow::tuple<OutputTypes...> > :
public graph_node {
4106 static const size_t NUM_OUTPUTS =
sizeof...(OutputTypes);
4112 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4123 template<
typename T>
4127 my_output_ports = tbb::internal::make_unique<output_ports_type>(std::forward<T>(output_ports_tuple));
4132 template<
typename... NodeTypes >
4135 template<
typename... NodeTypes >
4138 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4145 __TBB_ASSERT(my_output_ports,
"output ports not set, call set_external_ports to set output ports");
4146 return *my_output_ports;
4149 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4151 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
4157 #endif // __TBB_FLOW_GRAPH_CPP11_FEATURES
4159 namespace internal {
4161 template<
typename Gateway>
4168 my_gateway = gateway;
4175 template<
typename Input,
typename Ports,
typename Gateway,
typename Body>
4185 my_body(v, *this->my_gateway);
4197 namespace interface11 {
4200 template <
typename Input,
typename Output,
4204 :
public multifunction_node< Input, tuple< Output >, Policy, Allocator >,
public sender< Output >
4206 #if !TBB_DEPRECATED_FLOW_NODE_ALLOCATOR
4209 "Allocator template parameter for flow graph nodes is deprecated and will removed in the future. "
4210 "To temporary enable the deprecated interface specify TBB_ENABLE_DEPRECATED_NODE_ALLOCATOR."
4235 result = port->try_put(*
value);
4244 my_node->my_graph.reserve_wait();
4248 my_node->my_graph.release_wait();
4254 return my_node->try_put_impl(i);
4272 "Return status is inconsistent with the method operation." );
4274 while( !tasks.
empty() ) {
4278 return is_at_least_one_put_successful;
4282 template<
typename Body>
4284 graph &g,
size_t concurrency,
4294 tbb::internal::fgt_multioutput_node_with_body<1>(
4295 CODEPTR(), tbb::internal::FLOW_ASYNC_NODE,
4297 this->output_ports(), this->my_body
4301 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES && __TBB_CPP11_PRESENT
4302 template <
typename Body,
typename... Args>
4304 : async_node(g, concurrency, body, Policy(), priority) {}
4305 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
4307 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
4308 template <
typename Body,
typename... Args>
4310 const node_set<Args...>& nodes,
size_t concurrency, Body body,
4313 make_edges_in_order(nodes, *
this);
4316 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
4317 template <
typename Body,
typename... Args>
4319 : async_node(nodes, concurrency, body, Policy(), priority) {}
4320 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
4321 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
4325 static_cast<async_body_base_type*
>(this->my_init_body->get_body_ptr())->set_gateway(&my_gateway);
4327 tbb::internal::fgt_multioutput_node_with_body<1>(
CODEPTR(), tbb::internal::FLOW_ASYNC_NODE,
4329 this->output_ports(), this->my_body );
4336 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4346 return internal::output_port<0>(*this).register_successor(r);
4351 return internal::output_port<0>(*this).remove_successor(r);
4354 template<
typename Body>
4358 mfn_body_type &body_ref = *this->my_body;
4360 return ab.get_body();
4363 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4364 typedef typename internal::edge_container<successor_type> built_successors_type;
4366 typedef typename built_successors_type::edge_list_type successor_list_type;
4368 return internal::output_port<0>(*this).built_successors();
4371 void internal_add_built_successor( successor_type &r )
__TBB_override {
4372 internal::output_port<0>(*this).internal_add_built_successor(r);
4375 void internal_delete_built_successor( successor_type &r )
__TBB_override {
4376 internal::output_port<0>(*this).internal_delete_built_successor(r);
4380 internal::output_port<0>(*this).copy_successors(l);
4384 return internal::output_port<0>(*this).successor_count();
4391 base_type::reset_node(f);
4395 #if __TBB_PREVIEW_STREAMING_NODE
4397 #endif // __TBB_PREVIEW_STREAMING_NODE
4401 template<
typename T >
4408 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4421 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
4422 template <
typename... Args>
4423 overwrite_node(
const node_set<Args...>& nodes) : overwrite_node(nodes.graph_reference()) {
4424 make_edges_in_order(nodes, *
this);
4430 graph_node(src.my_graph),
receiver<T>(),
sender<T>(), my_buffer_is_valid(false)
4439 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4449 bool ret = s.try_put( my_buffer );
4458 task *rtask =
new ( task::allocate_additional_child_of( *( my_graph.root_task() ) ) )
4475 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4476 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
4477 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
4479 void internal_add_built_successor( successor_type &s)
__TBB_override {
4481 my_successors.internal_add_built_successor(s);
4484 void internal_delete_built_successor( successor_type &s)
__TBB_override {
4486 my_successors.internal_delete_built_successor(s);
4491 return my_successors.successor_count();
4496 my_successors.copy_successors(v);
4499 void internal_add_built_predecessor( predecessor_type &p)
__TBB_override {
4501 my_built_predecessors.add_edge(p);
4504 void internal_delete_built_predecessor( predecessor_type &p)
__TBB_override {
4506 my_built_predecessors.delete_edge(p);
4511 return my_built_predecessors.edge_count();
4514 void copy_predecessors( predecessor_list_type &v )
__TBB_override {
4516 my_built_predecessors.copy_edges(v);
4520 my_buffer_is_valid =
false;
4521 built_successors().sender_extract(*
this);
4522 built_predecessors().receiver_extract(*
this);
4529 if ( my_buffer_is_valid ) {
4549 return my_buffer_is_valid;
4554 my_buffer_is_valid =
false;
4564 return try_put_task_impl(v);
4569 my_buffer_is_valid =
true;
4583 o(owner), s(succ) {};
4586 if (!s.register_predecessor(o)) {
4587 o.register_successor(s);
4598 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
4599 internal::edge_container<predecessor_type> my_built_predecessors;
4606 my_buffer_is_valid =
false;
4607 if (f&rf_clear_edges) {
4608 my_successors.
clear();
4613 template<
typename T >
4629 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
4630 template <
typename... Args>
4631 write_once_node(
const node_set<Args...>& nodes) : write_once_node(nodes.graph_reference()) {
4632 make_edges_in_order(nodes, *
this);
4643 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
4655 return this->my_buffer_is_valid ? NULL : this->try_put_task_impl(v);
4666 using interface11::graph;
4667 using interface11::graph_node;
4668 using interface11::continue_msg;
4669 using interface11::source_node;
4670 using interface11::input_node;
4671 using interface11::function_node;
4672 using interface11::multifunction_node;
4673 using interface11::split_node;
4675 using interface11::indexer_node;
4676 using interface11::internal::tagged_msg;
4679 using interface11::continue_node;
4680 using interface11::overwrite_node;
4681 using interface11::write_once_node;
4682 using interface11::broadcast_node;
4683 using interface11::buffer_node;
4684 using interface11::queue_node;
4685 using interface11::sequencer_node;
4686 using interface11::priority_queue_node;
4687 using interface11::limiter_node;
4688 using namespace interface11::internal::graph_policy_namespace;
4689 using interface11::join_node;
4695 #if __TBB_FLOW_GRAPH_CPP11_FEATURES
4696 using interface11::composite_node;
4698 using interface11::async_node;
4699 #if __TBB_PREVIEW_ASYNC_MSG
4702 #if __TBB_PREVIEW_STREAMING_NODE
4705 #endif // __TBB_PREVIEW_STREAMING_NODE
4706 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
4711 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
4712 using interface11::internal::follows;
4713 using interface11::internal::precedes;
4714 using interface11::internal::make_node_set;
4715 using interface11::internal::make_edges;
4724 #undef __TBB_PFG_RESET_ARG
4726 #undef __TBB_DEFAULT_NODE_ALLOCATOR
4729 #undef __TBB_flow_graph_H_include_area
4731 #if TBB_USE_THREADING_TOOLS && TBB_PREVIEW_FLOW_GRAPH_TRACE && ( __linux__ || __APPLE__ )
4732 #undef __TBB_NOINLINE_SYM
4735 #endif // __TBB_flow_graph_H
Used to form groups of tasks.
Body copy_function_object()
untyped_receiver successor_type
The successor type for this node.
tuple< T0, T1, T2 > InputTuple
void try_put_and_add_task(task *&last_task)
tbb::flow::tuple< sender< OutputTypes > &... > output_ports_type
void reset_node(reset_flags) __TBB_override
receiver< input_type >::predecessor_type predecessor_type
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
void const char const char int ITT_FORMAT __itt_group_sync s
static void alias_port(void *, PortsTuple &)
void add_nodes(const NodeTypes &...n)
void internal_forward_task(queue_operation *op) __TBB_override
Tries to forward valid items to successors.
A cache of predecessors that only supports try_get.
output_type my_cached_item
virtual void reset_node(reset_flags f=rf_reset_protocol)=0
buffer_node< T, Allocator > base_type
task * try_put_task(const T &v) __TBB_override
Put item to successor; return task to run the successor if possible.
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
bool internal_push(sequencer_operation *op) __TBB_override
virtual task * execute()=0
Should be overridden by derived classes.
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
void internal_reserve(queue_operation *op) __TBB_override
Base class for tasks generated by graph nodes.
virtual void internal_forward_task(buffer_operation *op)
Tries to forward valid items to successors.
bool try_reserve(X &t)
Reserves an item in the sender.
receiver< TupleType > base_type
static void fgt_multioutput_node_desc(const NodeType *, const char *)
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
tbb::spin_mutex nodelist_mutex
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
internal::wrap_tuple_elements< tbb::flow::tuple_size< kernel_input_tuple >::value, internal::multifunction_output, kernel_input_tuple >::type output_ports_type
tuple< T0, T1, T2, T3, T4, T5 > InputTuple
~source_node()
The destructor.
bool remove_predecessor(predecessor_type &src) __TBB_override
Removes src from the list of cached predecessors.
internal::function_input_queue< input_type, internals_allocator > input_queue_type
cache_aligned_allocator< Input > internals_allocator
virtual bool remove_predecessor(predecessor_type &)
Remove a predecessor from the node.
unfolded_type::input_ports_type input_ports_type
tbb::task_group_context * my_context
void add_nodes(const NodeTypes &...n)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
buffer_operation(op_type t)
bool try_consume() __TBB_override
Consumes a reserved item.
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
void remove_edge(sender< T > &p, receiver< T > &s)
Removes an edge between a single predecessor and a single successor.
Base class for receivers of completion messages.
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
Enables one or the other code branches.
void register_successor(successor_type &r)
An abstract cache of successors.
output_ports_type & output_ports()
internal::unfolded_indexer_node< InputTuple > unfolded_type
internal::async_body_base< gateway_type > async_body_base_type
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed...
bool remove_successor(successor_type &s) __TBB_override
Removes a successor from this node.
void reset_node(reset_flags f) __TBB_override
buffer_operation(const T &e, op_type t)
static void fgt_node_with_body(void *, string_index, void *, void *, void *)
void internal_consume(prio_operation *op) __TBB_override
graph & graph_reference() const __TBB_override
sender< output_type >::successor_type successor_type
The type of successors of this node.
internal::broadcast_cache< output_type > & successors() __TBB_override
__TBB_DEPRECATED typedef receiver< input_type >::predecessor_type predecessor_type
The predecessor type for this node.
sender< output_type >::successor_type successor_type
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
internal::aggregator< handler_type, buffer_operation > my_aggregator
__TBB_DEPRECATED bool remove_predecessor(predecessor_type &) __TBB_override
Decrements the trigger threshold.
sender< output_type >::successor_type successor_type
void internal_pop(queue_operation *op) __TBB_override
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, __TBB_B7 b7, __TBB_B8 b8)
__TBB_DEPRECATED continue_receiver(__TBB_FLOW_GRAPH_PRIORITY_ARG1(int number_of_predecessors, node_priority_t priority))
Constructor.
output_ports_type & output_ports()
bool try_reserve_apply_body(output_type &v)
receiver_type::predecessor_type predecessor_type
#define __TBB_DEPRECATED_LIMITER_ARG4(arg1, arg2, arg3, arg4)
internal::unfolded_indexer_node< InputTuple > unfolded_type
wrap_tuple_elements< N, PT, OutputTuple >::type input_ports_type
input_ports_type & input_ports()
task * try_put_task(const X &t)
static const T & from_void_ptr(const void *p)
internal::unfolded_indexer_node< InputTuple > unfolded_type
void reserve_wait() __TBB_override
Inform a graph that messages may come from outside, to prevent premature graph completion.
broadcast_cache_type & successors()
bool try_consume() __TBB_override
Consumes a reserved item.
concurrency
An enumeration the provides the two most common concurrency levels: unlimited and serial...
virtual bool try_get_wrapper(void *p, bool is_async) __TBB_override
void try_put_and_add_task(task *&last_task)
__TBB_NOINLINE_SYM indexer_node(graph &g)
void set_external_ports(T &&output_ports_tuple)
task * apply_body_bypass()
Applies the body. Returning SUCCESSFULLY_ENQUEUED okay; forward_task_bypass will handle it...
Base class for user-defined tasks.
input_impl_type::predecessor_type predecessor_type
buffer_node< T, Allocator >::buffer_operation prio_operation
indexer_node(const indexer_node &other)
A task that calls a node's forward_task function.
Implements methods for an executable node that takes continue_msg as input.
void reset_node(reset_flags f) __TBB_override
sender< output_type >::successor_type successor_type
bool register_successor(successor_type &s) __TBB_override
Add a new successor to this node.
async_storage_ptr my_storage
__TBB_NOINLINE_SYM write_once_node(const write_once_node &src)
Copy constructor: call base class copy constructor.
void internal_consume(queue_operation *op) __TBB_override
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1(arg1, priority)
bool register_successor(successor_type &r) __TBB_override
Adds a new successor.
virtual void reset_receiver(reset_flags f=rf_reset_protocol)=0
put receiver back in initial state
void reset_node(reset_flags f) __TBB_override
virtual bool try_reserve_wrapper(void *p, bool is_async)=0
task * try_put_task(const input_type &v) __TBB_override
Put item to successor; return task to run the successor if possible.
graph & graph_reference() const __TBB_override
task * try_put_task(const X &t)
item_buffer with reservable front-end. NOTE: if reserving, do not
void add_task_to_graph_reset_list(tbb::flow::interface10::graph &g, tbb::task *tp)
bool try_consume() __TBB_override
Consumes the reserved item.
__TBB_DEPRECATED bool register_predecessor(predecessor_type &) __TBB_override
Increments the trigger threshold.
receiver< input_type >::predecessor_type predecessor_type
sender< output_type >::successor_type successor_type
internal::function_input< input_type, output_type, Policy, internals_allocator > input_impl_type
static void fgt_remove_edge(void *, void *)
base_type::size_type size_type
static const bool is_async_type
pointer operator->() const
Dereference.
tuple< T0, T1, T2, T3, T4, T5, T6, T7 > InputTuple
virtual bool try_get_wrapper(void *p, bool is_async)=0
task * try_put_task_impl(const input_type &v)
__TBB_NOINLINE_SYM input_node(const input_node &src)
Copy constructor.
void handle_operations(prio_operation *op_list) __TBB_override
virtual task * try_put_task_wrapper(const void *p, bool is_async)=0
bool try_release() __TBB_override
Releases the reserved item.
tbb::flow::tuple< receiver< InputTypes > &... > input_ports_type
Forwards messages in arbitrary order.
function_body that takes an Input and a set of output ports
unsigned int node_priority_t
task * try_put_task(const T &t) __TBB_override
build a task to run the successor if possible. Default is old behavior.
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
bool try_put(const X &t)
Put an item to the receiver.
task * decrement_counter(long long delta)
tbb::flow::interface11::graph_iterator< graph, tbb::flow::interface11::graph_node > iterator
field of type K being used for matching.
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4)
internal::unfolded_indexer_node< InputTuple > unfolded_type
input_ports_type & input_ports()
internal::round_robin_cache< T, null_rw_mutex > my_successors
bool register_predecessor(predecessor_type &src) __TBB_override
Adds src to the list of cached predecessors.
virtual bool try_release()
Releases the reserved item.
An cache of predecessors that supports requests and reservations.
internal::function_input_queue< input_type, internals_allocator > input_queue_type
void reset_node(reset_flags f) __TBB_override
resets the source_node to its initial state
__TBB_NOINLINE_SYM broadcast_node(graph &g)
internal::unfolded_indexer_node< InputTuple > unfolded_type
void reset_node(reset_flags) __TBB_override
tbb::internal::uint64_t tag_value
#define __TBB_FLOW_GRAPH_PRIORITY_ARG0(priority)
tuple< T0, T1, T2, T3 > InputTuple
graph_iterator()
Default constructor.
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2)
K key_from_message(const opencl_async_msg< T, Factory > &dmsg)
internal::broadcast_cache< output_type > my_successors
internal::unfolded_join_node< N, key_matching_port, OutputTuple, key_matching< K, KHash > > unfolded_type
__TBB_NOINLINE_SYM multifunction_node(graph &g, size_t concurrency,)
__TBB_NOINLINE_SYM priority_queue_node(const priority_queue_node &src)
Copy constructor.
void add_nodes_impl(CompositeType *, bool)
gateway_type * my_gateway
static void fgt_begin_body(void *)
__TBB_NOINLINE_SYM indexer_node(graph &g)
static void fgt_release_wait(void *)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
task that does nothing. Useful for synchronization.
internal::source_body< output_type > * my_init_body
__TBB_NOINLINE_SYM join_node(const join_node &other)
__TBB_NOINLINE_SYM indexer_node(graph &g)
void reset_node(reset_flags f) __TBB_override
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7 > output_type
std::unique_ptr< input_ports_type > my_input_ports
Forwards messages of type T to all successors.
A task that calls a node's apply_body_bypass function with no input.
#define __TBB_STATIC_ASSERT(condition, msg)
class __TBB_DEPRECATED streaming_node
bool is_continue_receiver() __TBB_override
internal::reservable_predecessor_cache< T, spin_mutex > my_predecessors
tbb::flow::interface11::graph_iterator< const graph, const tbb::flow::interface11::graph_node > const_iterator
static void clear_this(P &p)
void add_visible_nodes(const NodeTypes &...n)
internal::unfolded_indexer_node< InputTuple > unfolded_type
An executable node that acts as a source, i.e. it has no predecessors.
void internal_forward_task(prio_operation *op) __TBB_override
Tries to forward valid items to successors.
__TBB_DEPRECATED continue_receiver(const continue_receiver &src)
Copy constructor.
friend class proxy_dependency_receiver
std::unique_ptr< input_ports_type > my_input_ports
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, __TBB_B7 b7, __TBB_B8 b8, __TBB_B9 b9)
internal::broadcast_cache< output_type > & successors() __TBB_override
void reset_node(reset_flags f) __TBB_override
bool try_reserve(output_type &v) __TBB_override
Reserves an item.
virtual task * try_put_task_wrapper(const void *p, bool is_async) __TBB_override
__TBB_DEPRECATED typedef internal::async_helpers< T >::filtered_type filtered_type
#define __TBB_DEPRECATED_LIMITER_ARG2(arg1, arg2)
__TBB_NOINLINE_SYM composite_node(graph &g)
internal::multifunction_input< Input, typename base_type::output_ports_type, Policy, Allocator > mfn_input_type
static void fgt_composite(void *, void *, void *)
limiter_node(graph &g, __TBB_DEPRECATED_LIMITER_ARG2(size_t threshold, int num_decrement_predecessors=0))
Constructor.
__TBB_NOINLINE_SYM queue_node(graph &g)
Constructor.
multifunction_node< Input, tuple< Output >, Policy, Allocator > base_type
bool empty() const
True if list is empty; false otherwise.
bool try_release() __TBB_override
Release a reserved item.
virtual void internal_reserve(buffer_operation *op)
~graph()
Destroys the graph.
void remove_successor(successor_type &r)
virtual void handle_operations(buffer_operation *op_list)
tbb::flow::tuple_element< N, typename JNT::input_ports_type >::type & input_port(JNT &jn)
templated function to refer to input ports of the join node
receiver< input_type >::predecessor_type predecessor_type
output_ports_type my_output_ports
virtual task * execute()=0
Does whatever should happen when the threshold is reached.
An executable node that acts as a source, i.e. it has no predecessors.
void reserve_wait() __TBB_override
Used to register that an external entity may still interact with the graph.
receiver_gateway_impl(async_node *node)
register_predecessor_task(predecessor_type &owner, successor_type &succ)
void reset_receiver(reset_flags f) __TBB_override
put receiver back in initial state
void set_external_ports(T &&input_ports_tuple)
#define __TBB_CPP11_PRESENT
virtual void internal_rem_succ(buffer_operation *op)
Remove successor.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id parent
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
internal::continue_input< Output, Policy > input_impl_type
bool is_graph_active(tbb::flow::interface10::graph &g)
static void fgt_async_commit(void *, void *)
void wait_for_all()
Wait until graph is idle and decrement_wait_count calls equals increment_wait_count calls...
virtual void internal_release(buffer_operation *op)
internal::unfolded_indexer_node< InputTuple > unfolded_type
__TBB_NOINLINE_SYM buffer_node(graph &g)
Constructor.
__TBB_NOINLINE_SYM join_node(graph &g)
tbb::flow::interface11::graph_node * my_nodes
receiver_gateway< output_type > gateway_type
receiver< input_type >::predecessor_type predecessor_type
void deactivate_graph(tbb::flow::interface10::graph &g)
static void fgt_async_try_put_end(void *, void *)
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6)
Implements a function node that supports Input -> Output.
void remove_node(tbb::flow::interface11::graph_node *n)
Forwards messages in FIFO order.
Class for determining type of std::allocator<T>::value_type.
void internal_reserve(prio_operation *op) __TBB_override
buffer_node< T, Allocator >::size_type size_type
cache_aligned_allocator< T > internals_allocator
fOutput_type::successor_type successor_type
Implements an executable node that supports continue_msg -> Output.
__TBB_NOINLINE_SYM join_node(const join_node &other)
unfolded_join_node : passes input_ports_type to join_node_base. We build the input port type ...
overwrite_node< T > base_type
virtual graph & graph_reference() const =0
internal::broadcast_cache< T > my_successors
receiver< input_type >::predecessor_type predecessor_type
virtual bool register_predecessor(predecessor_type &)
Add a predecessor to the node.
Forwards messages in priority order.
Implements methods for a function node that takes a type Input as input.
reference operator*() const
Dereference.
priority_queue_node class_type
sender< output_type >::successor_type successor_type
__TBB_NOINLINE_SYM broadcast_node(const broadcast_node &src)
tuple< T0, T1 > InputTuple
internal::wrap_tuple_elements< N, internal::multifunction_output, TupleType >::type output_ports_type
static const node_priority_t no_priority
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > output_type
void activate_graph(tbb::flow::interface10::graph &g)
void handle_operations_impl(buffer_operation *op_list, derived_type *derived)
virtual bool is_continue_receiver()
void spawn_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
void set_gateway(gateway_type *gateway)
tbb::flow::interface11::graph_node * my_nodes_last
#define __TBB_DEPRECATED_LIMITER_EXPR(expr)
async_body_base(gateway_type *gateway)
void increment_ref_count()
Atomically increment reference count.
bool try_reserve(T &v) __TBB_override
Reserves an item.
Represents acquisition of a mutex.
void reset_node(reset_flags f) __TBB_override
Forwards messages only if the threshold has not been reached.
__TBB_DEPRECATED internal::port_ref_impl< N1, N2 > port_ref()
class __TBB_DEPRECATED_MSG("tbb::tbb_hash is deprecated, use std::hash") tbb_hash
__TBB_NOINLINE_SYM indexer_node(graph &g)
internal::tagged_msg< size_t, T0, T1, T2, T3 > output_type
void release_wait() __TBB_override
Deregisters an external entity that may have interacted with the graph.
__TBB_NOINLINE_SYM indexer_node(graph &g)
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1)
buffer_node< T, Allocator >::size_type size_type
buffer_node< T, Allocator >::item_type item_type
static void fgt_graph_desc(void *, const char *)
static tbb::task * combine_tasks(graph &g, tbb::task *left, tbb::task *right)
void release_wait() __TBB_override
Inform a graph that a previous call to reserve_wait is no longer in effect.
static tbb::task *const SUCCESSFULLY_ENQUEUED
task & pop_front()
Pop the front task from the list.
__TBB_NOINLINE_SYM multifunction_node(const multifunction_node &other)
internal::source_body< output_type > * my_body
internal::source_body< output_type > * my_body
void internal_forward_task_impl(buffer_operation *op, derived_type *derived)
A lock that occupies a single byte.
A cache of successors that are broadcast to.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
void internal_make_edge(internal::untyped_sender &p, internal::untyped_receiver &s)
static const void * to_void_ptr(const T &t)
sender< output_type >::successor_type successor_type
static void fgt_reserve_wait(void *)
void internal_remove_edge(internal::untyped_sender &p, internal::untyped_receiver &s)
__TBB_NOINLINE_SYM sequencer_node(graph &g, const Sequencer &s)
Constructor.
void register_node(tbb::flow::interface11::graph_node *n)
buffer_node< T, Allocator > base_type
output_ports_type & output_ports()
virtual void internal_pop(buffer_operation *op)
#define __TBB_DEFAULT_NODE_ALLOCATOR(T)
GraphNodeType & reference
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
Base class for types that should not be assigned.
sender< output_type >::successor_type successor_type
int decrement_ref_count()
Atomically decrement reference count and returns its new value.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
internal::unfolded_indexer_node< InputTuple > unfolded_type
__TBB_NOINLINE_SYM indexer_node(graph &g)
static void fgt_async_try_put_begin(void *, void *)
Body copy_function_object()
buffer_node< T, Allocator > class_type
virtual bool internal_push(buffer_operation *op)
void prepare_task_arena(bool reinit=false)
fOutput_type::successor_type successor_type
virtual bool register_successor(successor_type &r)=0
Add a new successor to this node.
iterator begin()
start iterator
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
The base of all graph nodes.
bool try_release() __TBB_override
Release a reserved item.
bool register_successor(successor_type &r) __TBB_override
Add a new successor to this node.
Body copy_body(Node &n)
Returns a copy of the body from a function or continue node.
graph & graph_reference() const __TBB_override
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark S
bool try_get(X &t)
Request an item from the sender.
internal::tagged_msg< size_t, T0, T1, T2 > output_type
const V & cast_to(T const &t)
internal::unfolded_join_node< N, queueing_port, OutputTuple, queueing > unfolded_type
void const char const char int ITT_FORMAT __itt_group_sync p
virtual task * forward_task()
This is executed by an enqueued task, the "forwarder".
iterator end()
end iterator
split_node: accepts a tuple as input, forwards each element of the tuple to its
__TBB_NOINLINE_SYM buffer_node(const buffer_node &src)
Copy constructor.
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
receiver< input_type > receiver_type
static task * try_put_task_wrapper_impl(receiver< T > *const this_recv, const void *p, bool is_async)
__TBB_NOINLINE_SYM async_node(const async_node &other)
void add_visible_nodes(const NodeTypes &...n)
graph & graph_reference() const __TBB_override
void reset_node(reset_flags f) __TBB_override
internal::function_output< output_type > fOutput_type
bool try_get(T &v) __TBB_override
Request an item from the buffer_node.
graph()
Constructs a graph with isolated task_group_context.
tuple< T0, T1, T2, T3, T4 > InputTuple
task_list_type my_reset_task_list
__TBB_NOINLINE_SYM continue_node(graph &g,)
Constructor for executable node with continue_msg -> Output.
__TBB_NOINLINE_SYM overwrite_node(graph &g)
bool remove_successor(successor_type &r) __TBB_override
Removes s as a successor.
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Forward declaration section.
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8 > output_type
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5)
leaf for multifunction. OutputSet can be a std::tuple or a vector.
tbb::flow::tuple< receiver< InputTypes > &... > input_ports_type
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5 > output_type
buffer_node< T, Allocator >::buffer_operation sequencer_operation
std::unique_ptr< output_ports_type > my_output_ports
internal::decrementer< limiter_node< T, DecrementType >, DecrementType > decrement
The internal receiver< DecrementType > that decrements the count.
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
task * try_put_task(const input_type &) __TBB_override
virtual task * try_put_task(const T &t)=0
Put item to successor; return task to run the successor if possible.
tbb::task_arena * my_task_arena
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, __TBB_B7 b7)
bool try_consume() __TBB_override
Consumes a reserved item.
task * try_put_task(const T &t) __TBB_override
receive an item, return a task *if possible
task * grab_forwarding_task(buffer_operation &op_data)
interface11::internal::Policy< queueing, lightweight > queueing_lightweight
internal::broadcast_cache< output_type > my_successors
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
Implements methods for both executable and function nodes that puts Output to its successors...
unfolded_type::input_ports_type input_ports_type
The leaf for source_body.
internal::tagged_msg< size_t, T0, T1, T2, T3, T4 > output_type
#define __TBB_NOINLINE_SYM
__TBB_DEPRECATED typedef internal::async_helpers< T >::filtered_type filtered_type
static void alias_port(void *, PortsTuple &)
internal::multifunction_input< input_type, output_ports_type, Policy, internals_allocator > input_impl_type
tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > InputTuple
std::unique_ptr< output_ports_type > my_output_ports
~input_node()
The destructor.
Pure virtual template class that defines a receiver of messages of type T.
static task * try_put_task_wrapper_impl(receiver< T > *const this_recv, const void *p, bool is_async)
static void fgt_node_desc(const NodeType *, const char *)
~sequencer_node()
Destructor.
static void fgt_make_edge(void *, void *)
bool try_reserve(output_type &v) __TBB_override
Reserves an item.
void internal_pop(prio_operation *op) __TBB_override
sender< output_type >::successor_type successor_type
receiver< input_type >::predecessor_type predecessor_type
bool try_put(const Output &i) __TBB_override
Implements gateway_type::try_put for an external activity to submit a message to FG.
bool try_get(output_type &v) __TBB_override
Request an item from the node.
internal::multifunction_output< Output > output_port_type
__TBB_NOINLINE_SYM source_node(graph &g, Body body, bool is_active=true)
Constructor for a node with a successor.
virtual ~untyped_receiver()
Destructor.
__TBB_NOINLINE_SYM join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3)
tuple< T0, T1, T2, T3, T4, T5, T6 > InputTuple
graph & graph_reference() const __TBB_override
__TBB_NOINLINE_SYM async_node(graph &g, size_t concurrency,)
__TBB_NOINLINE_SYM indexer_node(graph &g)
internal::unfolded_join_node< N, reserving_port, OutputTuple, reserving > unfolded_type
void spawn_put()
Spawns a task that applies the body.
try_put_functor(output_port_type &p, const Output &v)
virtual bool try_reserve_wrapper(void *p, bool is_async) __TBB_override
static void fgt_multiinput_multioutput_node(void *, string_index, void *, void *)
__TBB_NOINLINE_SYM function_node(graph &g, size_t concurrency, __TBB_FLOW_GRAPH_PRIORITY_ARG1(Body body, node_priority_t priority=tbb::flow::internal::no_priority))
Constructor.
tbb::flow::tuple_element< N, typename MOP::output_ports_type >::type & output_port(MOP &op)
static void fgt_node(void *, string_index, void *, void *)
virtual source_body * clone()=0
const_iterator cbegin() const
start const iterator
internal::tagged_msg< size_t, T0, T1 > output_type
void set_ref_count(int count)
Set reference count.
bool register_successor(successor_type &r) __TBB_override
Replace the current successor with this new successor.
unfolded_type::input_ports_type input_ports_type
bool try_put(const typename internal::async_helpers< T >::filtered_type &t)
Put an item to the receiver.
void activate()
Activates a node that was created in the inactive state.
bool enqueue_forwarding_task(buffer_operation &op_data)
virtual void finalize() const
async_msg< T > async_type
bool register_successor(successor_type &r) __TBB_override
Add a new successor to this node.
internal::unfolded_indexer_node< InputTuple > unfolded_type
__TBB_NOINLINE_SYM overwrite_node(const overwrite_node &src)
Copy constructor; doesn't take anything from src; default won't work.
untyped_sender predecessor_type
The predecessor type for this node.
bool register_successor(successor_type &r) __TBB_override
Adds a successor.
Detects whether two given types are the same.
__TBB_NOINLINE_SYM priority_queue_node(graph &g, const Compare &comp=Compare())
Constructor.
task * try_put_task(const TupleType &t) __TBB_override
Put item to successor; return task to run the successor if possible.
void try_put_and_add_task(task *&last_task)
async_body_base< Gateway > base_type
void call(F &&f, Pack &&p)
Calls the given function with arguments taken from a stored_pack.
void reset(tbb::flow::interface11::reset_flags f=tbb::flow::interface11::rf_reset_protocol)
static void fgt_graph(void *)
bool try_reserve(T &v) __TBB_override
Reserves an item.
An empty class used for messages that mean "I'm done".
virtual void internal_reg_succ(buffer_operation *op)
Register successor.
internal::function_body< T, size_t > * my_sequencer
class __TBB_DEPRECATED async_msg
void reset_node(reset_flags f) __TBB_override
A cache of successors that are put in a round-robin fashion.
__TBB_NOINLINE_SYM indexer_node(graph &g)
bool try_get(input_type &v) __TBB_override
Request an item from the sender.
Output output_type
The type of the output message, which is complete.
void reset_node(reset_flags f) __TBB_override
internal::tagged_msg< size_t, T0 > output_type
Body copy_function_object()
void set_external_ports(T1 &&input_ports_tuple, T2 &&output_ports_tuple)
void internal_release(prio_operation *op) __TBB_override
internal::source_body< output_type > * my_init_body
async_body(const Body &body, gateway_type *gateway)
static void * to_void_ptr(T &t)
receiver< input_type >::predecessor_type predecessor_type
__TBB_NOINLINE_SYM indexer_node(const indexer_node &other)
tbb::flow::tuple< sender< OutputTypes > &... > output_ports_type
input_impl_type::predecessor_type predecessor_type
__TBB_NOINLINE_SYM source_node(const source_node &src)
Copy constructor.
void reset_node(reset_flags f) __TBB_override
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
virtual bool try_reserve(T &)
Reserves an item in the sender.
__TBB_NOINLINE_SYM join_node(graph &g)
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
internal::wrap_tuple_elements< N, internal::multifunction_output, Output >::type output_ports_type
__TBB_DEPRECATED typedef continue_msg input_type
The input type.
void prio_push(const T &src)
void fgt_multiinput_multioutput_node_desc(const NodeType *, const char *)
virtual bool remove_successor(successor_type &r)=0
Removes a successor from this node.
limiter_node(const limiter_node &src)
Copy constructor.
__TBB_NOINLINE_SYM queue_node(const queue_node &src)
Copy constructor.
base_type::output_ports_type output_ports_type
sender< output_type >::successor_type successor_type
The type of successors of this node.
task * try_put_task(const T &t) __TBB_override
Puts an item to this receiver.
void make_edge(sender< T > &p, receiver< T > &s)
Makes an edge between a single predecessor and a single successor.
static const void * to_void_ptr(const T &t)
__TBB_NOINLINE_SYM split_node(const split_node &other)
receiver< input_type >::predecessor_type predecessor_type
void set_owner(owner_type *owner)
Forwards messages in sequence order.
cache_aligned_allocator< Input > internals_allocator
implements a function node that supports Input -> (set of outputs)
bool try_put_impl(const Output &i)
Implements gateway_type::try_put for an external activity to submit a message to FG.
#define __TBB_FLOW_GRAPH_PRIORITY_EXPR(expr)
__TBB_NOINLINE_SYM sequencer_node(const sequencer_node &src)
Copy constructor.
void spawn_put()
Spawns a task that applies the body.
void operator()(const Input &v, Ports &)
static void fgt_end_body(void *)
tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8 > InputTuple
bool gather_successful_try_puts(const X &t, task_list &tasks)
bool try_reserve_apply_body(output_type &v)
__TBB_NOINLINE_SYM continue_node(const continue_node &src)
Copy constructor.
task * apply_body_bypass()
Applies the body. Returning SUCCESSFULLY_ENQUEUED okay; forward_task_bypass will handle it...
__TBB_NOINLINE_SYM write_once_node(graph &g)
Constructor.
static task * emit_this(graph &g, const T &t, P &p)
__TBB_DEPRECATED typedef T output_type
The output type of this sender.
__TBB_NOINLINE_SYM join_node(const join_node &other)
bool remove_successor(successor_type &r) __TBB_override
Removes a successor.
int my_initial_predecessor_count
internal::unfolded_indexer_node< InputTuple > unfolded_type
virtual ~untyped_sender()
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
bool try_get(output_type &v) __TBB_override
Request an item from the node.
internal::aggregating_functor< class_type, buffer_operation > handler_type
Implements methods for a function node that takes a type Input as input and sends.
output_type my_cached_item
bool internal_push(prio_operation *op) __TBB_override
Output output_type
The type of the output message, which is complete.
virtual bool try_get(T &)
Request an item from the sender.
void add_visible_nodes(const NodeTypes &...n)
void __TBB_store_with_release(volatile T &location, V value)
void reset_node(reset_flags f) __TBB_override
void activate()
Activates a node that was created in the inactive state.
__TBB_NOINLINE_SYM indexer_node(graph &g)
static void fgt_async_reserve(void *, void *)
void enqueue_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Enqueues a task inside graph arena.
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6 > output_type
virtual void internal_consume(buffer_operation *op)
__TBB_DEPRECATED typedef T input_type
The input type of this receiver.
base_type::buffer_operation queue_operation
bool try_release() __TBB_override
Release a reserved item.
Breaks an infinite loop between the node reservation and register_successor call. ...
internal::function_output< output_type > fOutput_type
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
void reset_node(reset_flags f) __TBB_override
resets the source_node to its initial state
virtual bool try_consume()
Consumes the reserved item.
void reset_node(reset_flags) __TBB_override
const_iterator cend() const
end const iterator
sender< output_type >::successor_type successor_type
void add_nodes(const NodeTypes &...n)
bool register_successor(successor_type &r) __TBB_override
Add a new successor to this node.