21 #ifndef __TBB_flow_graph_H 22 #define __TBB_flow_graph_H 38 #if __TBB_PREVIEW_ASYNC_MSG 43 #if __TBB_PREVIEW_STREAMING_NODE 46 #include <unordered_map> 47 #include <type_traits> 48 #endif // __TBB_PREVIEW_STREAMING_NODE 50 #if TBB_DEPRECATED_FLOW_ENQUEUE 51 #define FLOW_SPAWN(a) tbb::task::enqueue((a)) 53 #define FLOW_SPAWN(a) tbb::task::spawn((a)) 57 #if __TBB_CPP11_TUPLE_PRESENT 62 using std::tuple_size;
63 using std::tuple_element;
68 #include "compat/tuple" 90 namespace interface10 {
113 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 117 class edge_container {
120 typedef std::list<C *, tbb::tbb_allocator<C *> > edge_list_type;
122 void add_edge(C &
s) {
123 built_edges.push_back(&
s);
126 void delete_edge(C &
s) {
127 for (
typename edge_list_type::iterator i = built_edges.begin(); i != built_edges.end(); ++i) {
135 void copy_edges(edge_list_type &v) {
139 size_t edge_count() {
140 return (
size_t)(built_edges.size());
149 template<
typename S >
void sender_extract(
S &
s);
150 template<
typename R >
void receiver_extract(R &r);
153 edge_list_type built_edges;
168 namespace interface10 {
173 if (right == NULL)
return left;
175 if (left == NULL)
return right;
186 #if __TBB_PREVIEW_ASYNC_MSG 194 template<
typename T,
typename =
void >
202 return static_cast<const void*>(&t);
206 return static_cast<void*>(&t);
210 return *static_cast<const T*>(
p);
214 return *static_cast<T*>(
p);
235 template<
typename T >
303 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 304 typedef internal::edge_container<successor_type> built_successors_type;
306 typedef built_successors_type::edge_list_type successor_list_type;
307 virtual built_successors_type &built_successors() = 0;
310 virtual void copy_successors( successor_list_type &) = 0;
311 virtual size_t successor_count() = 0;
315 template<
typename X >
321 template<
typename X >
338 #if __TBB_PREVIEW_OPENCL_NODE 352 if (!res)
return false;
367 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 368 typedef internal::edge_container<predecessor_type> built_predecessors_type;
369 typedef built_predecessors_type::edge_list_type predecessor_list_type;
370 virtual built_predecessors_type &built_predecessors() = 0;
373 virtual void copy_predecessors( predecessor_list_type & ) = 0;
374 virtual size_t predecessor_count() = 0;
397 template<
typename T >
418 __TBB_ASSERT(
false,
"async_msg interface does not support 'pull' protocol in try_get()");
428 __TBB_ASSERT(
false,
"async_msg interface does not support 'pull' protocol in try_reserve()");
434 template<
typename T >
463 #else // __TBB_PREVIEW_ASYNC_MSG 466 template<
typename T >
486 virtual bool try_get( T & ) {
return false; }
497 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 498 typedef typename internal::edge_container<successor_type> built_successors_type;
500 typedef typename built_successors_type::edge_list_type successor_list_type;
501 virtual built_successors_type &built_successors() = 0;
503 virtual void internal_delete_built_successor(
successor_type & ) = 0;
504 virtual void copy_successors( successor_list_type &) = 0;
505 virtual size_t successor_count() = 0;
510 template<
typename T >
525 if (!res)
return false;
546 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 547 typedef typename internal::edge_container<predecessor_type> built_predecessors_type;
548 typedef typename built_predecessors_type::edge_list_type predecessor_list_type;
549 virtual built_predecessors_type &built_predecessors() = 0;
552 virtual void copy_predecessors( predecessor_list_type & ) = 0;
553 virtual size_t predecessor_count() = 0;
564 #if __TBB_PREVIEW_OPENCL_NODE 569 #endif // __TBB_PREVIEW_ASYNC_MSG 611 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 612 typedef internal::edge_container<predecessor_type> built_predecessors_type;
613 typedef built_predecessors_type::edge_list_type predecessor_list_type;
614 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
618 my_built_predecessors.add_edge(
s );
623 my_built_predecessors.delete_edge(
s);
628 my_built_predecessors.copy_edges(v);
633 return my_built_predecessors.edge_count();
655 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 658 built_predecessors_type my_built_predecessors;
671 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 672 my_built_predecessors.clear();
689 #if __TBB_PREVIEW_MESSAGE_BASED_KEY_MATCHING 690 template <
typename K,
typename T>
707 namespace interface10 {
712 #if __TBB_PREVIEW_ASYNC_MSG 717 template <
typename C,
typename N>
720 if (
begin) current_node = my_graph->my_nodes;
724 template <
typename C,
typename N>
727 return *operator->();
730 template <
typename C,
typename N>
735 template <
typename C,
typename N>
737 if (current_node) current_node = current_node->next;
741 inline graph::graph() : my_nodes(NULL), my_nodes_last(NULL), my_task_arena(NULL) {
754 my_context(&use_this_context), my_nodes(NULL), my_nodes_last(NULL), my_task_arena(NULL) {
843 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 844 inline void graph::set_name(
const char *
name) {
850 my_graph.register_node(
this);
854 my_graph.remove_node(
this);
860 template <
typename Output >
872 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 878 template<
typename Body >
880 :
graph_node(g), my_active(is_active), init_my_active(is_active),
883 my_reserved(false), my_has_cached_item(false)
885 my_successors.set_owner(
this);
893 my_active(src.init_my_active),
894 init_my_active(src.init_my_active), my_body( src.my_init_body->clone() ), my_init_body(src.my_init_body->clone() ),
895 my_reserved(false), my_has_cached_item(false)
897 my_successors.set_owner(
this);
905 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 914 my_successors.register_successor(r);
923 my_successors.remove_successor(r);
927 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 929 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
931 void internal_add_built_successor( successor_type &r)
__TBB_override {
933 my_successors.internal_add_built_successor(r);
936 void internal_delete_built_successor( successor_type &r)
__TBB_override {
938 my_successors.internal_delete_built_successor(r);
943 return my_successors.successor_count();
948 my_successors.copy_successors(v);
958 if ( my_has_cached_item ) {
960 my_has_cached_item =
false;
976 if ( my_has_cached_item ) {
989 __TBB_ASSERT( my_reserved && my_has_cached_item,
"releasing non-existent reservation" );
991 if(!my_successors.empty())
999 __TBB_ASSERT( my_reserved && my_has_cached_item,
"consuming non-existent reservation" );
1000 my_reserved =
false;
1001 my_has_cached_item =
false;
1002 if ( !my_successors.empty() ) {
1012 if (!my_successors.empty())
1016 template<
typename Body>
1022 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1024 my_successors.built_successors().sender_extract(*
this);
1025 my_active = init_my_active;
1026 my_reserved =
false;
1027 if(my_has_cached_item) my_has_cached_item =
false;
1035 my_active = init_my_active;
1037 if(my_has_cached_item) {
1038 my_has_cached_item =
false;
1064 if ( my_reserved ) {
1067 if ( !my_has_cached_item ) {
1069 bool r = (*my_body)(my_cached_item);
1072 my_has_cached_item =
true;
1075 if ( my_has_cached_item ) {
1089 return (
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
1104 if ( !try_reserve_apply_body(v) )
1117 template <
typename Input,
typename Output = continue_msg,
typename Policy = queueing,
typename Allocator=cache_aligned_allocator<Input> >
1127 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1128 typedef typename input_impl_type::predecessor_list_type predecessor_list_type;
1129 typedef typename fOutput_type::successor_list_type successor_list_type;
1131 using input_impl_type::my_predecessors;
1137 template<
typename Body >
1153 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1159 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1161 my_predecessors.built_predecessors().receiver_extract(*
this);
1162 successors().built_successors().sender_extract(*
this);
1170 using input_impl_type::try_put_task;
1175 input_impl_type::reset_function_input(f);
1178 successors().clear();
1179 my_predecessors.clear();
1182 __TBB_ASSERT(this->my_predecessors.empty(),
"function_node predecessors not empty");
1189 template <
typename Input,
typename Output,
typename Policy = queueing,
typename Allocator=cache_aligned_allocator<Input> >
1195 typename internal::wrap_tuple_elements<
1196 tbb::flow::tuple_size<Output>::value,
1197 internal::multifunction_output,
1213 using input_impl_type::my_predecessors;
1215 template<
typename Body>
1218 tbb::internal::fgt_multioutput_node_with_body<N>( tbb::internal::FLOW_MULTIFUNCTION_NODE,
1220 this->output_ports(), this->my_body );
1225 tbb::internal::fgt_multioutput_node_with_body<N>( tbb::internal::FLOW_MULTIFUNCTION_NODE,
1227 this->output_ports(), this->my_body );
1230 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1236 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1238 my_predecessors.built_predecessors().receiver_extract(*
this);
1239 base_type::extract();
1249 template<
typename TupleType,
typename Allocator=cache_aligned_allocator<TupleType> >
1256 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1258 typedef typename base_type::predecessor_list_type predecessor_list_type;
1260 typedef typename predecessor_cache_type::built_predecessors_type built_predecessors_type;
1271 tbb::internal::fgt_multioutput_node<N>(tbb::internal::FLOW_SPLIT_NODE, &this->my_graph,
1276 tbb::internal::fgt_multioutput_node<N>(tbb::internal::FLOW_SPLIT_NODE, &this->my_graph,
1280 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1304 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1309 void internal_add_built_predecessor(predecessor_type&)
__TBB_override {}
1318 built_predecessors_type &built_predecessors()
__TBB_override {
return my_predessors; }
1321 built_predecessors_type my_predessors;
1329 template <
typename Output,
typename Policy =
internal::Policy<
void> >
1341 template <
typename Body >
1351 template <
typename Body >
1362 internal::function_output<Output>() {
1368 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1374 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1376 input_impl_type::my_built_predecessors.receiver_extract(*
this);
1377 successors().built_successors().sender_extract(*
this);
1385 using input_impl_type::try_put_task;
1389 input_impl_type::reset_receiver(f);
1396 template <
typename T>
1403 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1409 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1410 internal::edge_container<predecessor_type> my_built_predecessors;
1430 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1448 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1451 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
1453 void internal_add_built_successor(successor_type &r)
__TBB_override {
1454 my_successors.internal_add_built_successor(r);
1457 void internal_delete_built_successor(successor_type &r)
__TBB_override {
1458 my_successors.internal_delete_built_successor(r);
1462 return my_successors.successor_count();
1466 my_successors.copy_successors(v);
1469 typedef typename receiver<T>::built_predecessors_type built_predecessors_type;
1471 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
1473 void internal_add_built_predecessor( predecessor_type &
p)
__TBB_override {
1475 my_built_predecessors.add_edge(
p);
1480 my_built_predecessors.delete_edge(
p);
1485 return my_built_predecessors.edge_count();
1488 void copy_predecessors(predecessor_list_type &v)
__TBB_override {
1490 my_built_predecessors.copy_edges(v);
1494 my_built_predecessors.receiver_extract(*
this);
1495 my_successors.built_successors().sender_extract(*
this);
1519 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1520 my_built_predecessors.clear();
1528 template <
typename T,
typename A=cache_aligned_allocator<T> >
1531 typedef T input_type;
1536 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1544 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1545 internal::edge_container<predecessor_type> my_built_predecessors;
1550 enum op_type {reg_succ, rem_succ, req_item, res_item, rel_res, con_res, put_item, try_fwd_task
1551 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1552 , add_blt_succ, del_blt_succ,
1553 add_blt_pred, del_blt_pred,
1554 blt_succ_cnt, blt_pred_cnt,
1555 blt_succ_cpy, blt_pred_cpy
1563 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1568 predecessor_type *
p;
1570 successor_list_type *svec;
1571 predecessor_list_type *pvec;
1580 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
1581 , ltask(NULL), elem(const_cast<T*>(&e))
1583 , elem(const_cast<T*>(&e)) , ltask(NULL)
1590 typedef internal::aggregating_functor<class_type, buffer_operation>
handler_type;
1595 handle_operations_impl(op_list,
this);
1598 template<
typename derived_type>
1599 void handle_operations_impl(buffer_operation *op_list, derived_type* derived) {
1600 __TBB_ASSERT(static_cast<class_type*>(derived) ==
this,
"'this' is not a base class for derived");
1602 buffer_operation *tmp = NULL;
1603 bool try_forwarding =
false;
1606 op_list = op_list->next;
1607 switch (tmp->type) {
1608 case reg_succ: internal_reg_succ(tmp); try_forwarding =
true;
break;
1609 case rem_succ: internal_rem_succ(tmp);
break;
1610 case req_item: internal_pop(tmp);
break;
1611 case res_item: internal_reserve(tmp);
break;
1612 case rel_res: internal_release(tmp); try_forwarding =
true;
break;
1613 case con_res: internal_consume(tmp); try_forwarding =
true;
break;
1614 case put_item: try_forwarding = internal_push(tmp);
break;
1615 case try_fwd_task: internal_forward_task(tmp);
break;
1616 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1618 case add_blt_succ: internal_add_built_succ(tmp);
break;
1619 case del_blt_succ: internal_del_built_succ(tmp);
break;
1620 case add_blt_pred: internal_add_built_pred(tmp);
break;
1621 case del_blt_pred: internal_del_built_pred(tmp);
break;
1622 case blt_succ_cnt: internal_succ_cnt(tmp);
break;
1623 case blt_pred_cnt: internal_pred_cnt(tmp);
break;
1624 case blt_succ_cpy: internal_copy_succs(tmp);
break;
1625 case blt_pred_cpy: internal_copy_preds(tmp);
break;
1632 if (try_forwarding && !forwarder_busy) {
1634 forwarder_busy =
true;
1635 task *new_task =
new(task::allocate_additional_child_of(*(this->my_graph.root_task())))
internal::
1642 graph &g = this->my_graph;
1648 inline task *grab_forwarding_task( buffer_operation &op_data) {
1649 return op_data.ltask;
1653 task *ft = grab_forwarding_task(op_data);
1663 buffer_operation op_data(try_fwd_task);
1690 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1693 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
1695 virtual void internal_add_built_succ(buffer_operation *op) {
1696 my_successors.internal_add_built_successor(*(op->r));
1700 virtual void internal_del_built_succ(buffer_operation *op) {
1701 my_successors.internal_delete_built_successor(*(op->r));
1707 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
1709 virtual void internal_add_built_pred(buffer_operation *op) {
1710 my_built_predecessors.add_edge(*(op->p));
1714 virtual void internal_del_built_pred(buffer_operation *op) {
1715 my_built_predecessors.delete_edge(*(op->p));
1719 virtual void internal_succ_cnt(buffer_operation *op) {
1720 op->cnt_val = my_successors.successor_count();
1724 virtual void internal_pred_cnt(buffer_operation *op) {
1725 op->cnt_val = my_built_predecessors.edge_count();
1729 virtual void internal_copy_succs(buffer_operation *op) {
1730 my_successors.copy_successors(*(op->svec));
1734 virtual void internal_copy_preds(buffer_operation *op) {
1735 my_built_predecessors.copy_edges(*(op->pvec));
1745 return this->my_item_valid(this->my_tail - 1);
1754 this->destroy_back();
1760 virtual void internal_forward_task(buffer_operation *op) {
1761 internal_forward_task_impl(op,
this);
1764 template<
typename derived_type>
1766 __TBB_ASSERT(static_cast<class_type*>(derived) ==
this,
"'this' is not a base class for derived");
1768 if (this->my_reserved || !derived->is_item_valid()) {
1770 this->forwarder_busy =
false;
1774 task * last_task = NULL;
1775 size_type counter = my_successors.
size();
1776 for (; counter > 0 && derived->is_item_valid(); --counter)
1777 derived->try_put_and_add_task(last_task);
1779 op->
ltask = last_task;
1780 if (last_task && !counter) {
1785 forwarder_busy =
false;
1790 this->push_back(*(op->
elem));
1796 if(this->pop_back(*(op->
elem))) {
1805 if(this->reserve_front(*(op->
elem))) {
1813 virtual void internal_consume(buffer_operation *op) {
1814 this->consume_front();
1819 this->release_front();
1826 forwarder_busy(false) {
1835 internal::reservable_item_buffer<T>(),
receiver<T>(),
sender<T>() {
1836 forwarder_busy =
false;
1843 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 1858 my_aggregator.execute(&op_data);
1859 (
void)enqueue_forwarding_task(op_data);
1863 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1864 void internal_add_built_successor( successor_type &r)
__TBB_override {
1865 buffer_operation op_data(add_blt_succ);
1867 my_aggregator.execute(&op_data);
1871 buffer_operation op_data(del_blt_succ);
1873 my_aggregator.execute(&op_data);
1876 void internal_add_built_predecessor( predecessor_type &
p)
__TBB_override {
1877 buffer_operation op_data(add_blt_pred);
1879 my_aggregator.execute(&op_data);
1883 buffer_operation op_data(del_blt_pred);
1885 my_aggregator.execute(&op_data);
1889 buffer_operation op_data(blt_pred_cnt);
1890 my_aggregator.execute(&op_data);
1891 return op_data.cnt_val;
1895 buffer_operation op_data(blt_succ_cnt);
1896 my_aggregator.execute(&op_data);
1897 return op_data.cnt_val;
1900 void copy_predecessors( predecessor_list_type &v )
__TBB_override {
1901 buffer_operation op_data(blt_pred_cpy);
1903 my_aggregator.execute(&op_data);
1907 buffer_operation op_data(blt_succ_cpy);
1909 my_aggregator.execute(&op_data);
1918 r.remove_predecessor(*
this);
1921 my_aggregator.execute(&op_data);
1925 (
void)enqueue_forwarding_task(op_data);
1933 buffer_operation op_data(req_item);
1935 my_aggregator.execute(&op_data);
1936 (
void)enqueue_forwarding_task(op_data);
1946 my_aggregator.execute(&op_data);
1947 (
void)enqueue_forwarding_task(op_data);
1954 buffer_operation op_data(rel_res);
1955 my_aggregator.execute(&op_data);
1956 (
void)enqueue_forwarding_task(op_data);
1964 my_aggregator.execute(&op_data);
1965 (
void)enqueue_forwarding_task(op_data);
1976 buffer_operation op_data(t, put_item);
1977 my_aggregator.execute(&op_data);
1978 task *ft = grab_forwarding_task(op_data);
2000 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 2003 my_built_predecessors.receiver_extract(*
this);
2014 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 2015 my_built_predecessors.clear();
2018 forwarder_busy =
false;
2023 template <
typename T,
typename A=cache_aligned_allocator<T> >
2035 return this->my_item_valid(this->my_head);
2042 graph& graph_ref = this->graph_reference();
2044 this->destroy_front();
2050 this->internal_forward_task_impl(op,
this);
2054 if ( this->my_reserved || !this->my_item_valid(this->my_head)){
2058 this->pop_front(*(op->
elem));
2063 if (this->my_reserved || !this->my_item_valid(this->my_head)) {
2067 this->reserve_front(*(op->
elem));
2072 this->consume_front();
2096 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2104 base_type::reset_node(f);
2109 template<
typename T,
typename A=cache_aligned_allocator<T> >
2121 template<
typename Sequencer >
2123 my_sequencer(new internal::function_body_leaf< T, size_t, Sequencer>(
s) ) {
2131 my_sequencer( src.my_sequencer->clone() ) {
2140 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2153 #if !TBB_DEPRECATED_SEQUENCER_DUPLICATES 2154 if (tag < this->my_head) {
2161 size_t new_tail = (tag+1 > this->my_tail) ? tag+1 : this->my_tail;
2163 if (this->
size(new_tail) > this->capacity()) {
2164 this->grow_my_array(this->
size(new_tail));
2166 this->my_tail = new_tail;
2175 template<
typename T,
typename Compare = std::less<T>,
typename A=cache_aligned_allocator<T> >
2199 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2209 base_type::reset_node(f);
2218 this->internal_forward_task_impl(op,
this);
2222 this->handle_operations_impl(op_list,
this);
2226 prio_push(*(op->
elem));
2233 if ( this->my_reserved ==
true || this->my_tail == 0 ) {
2238 *(op->
elem) = prio();
2246 if (this->my_reserved ==
true || this->my_tail == 0) {
2250 this->my_reserved =
true;
2251 *(op->
elem) = prio();
2252 reserved_item = *(op->
elem);
2259 this->my_reserved =
false;
2265 prio_push(reserved_item);
2266 this->my_reserved =
false;
2274 if (mark < this->my_tail) heapify();
2275 __TBB_ASSERT(mark == this->my_tail,
"mark unequal after heapify");
2279 return this->my_tail > 0;
2286 graph& graph_ref = this->graph_reference();
2300 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds before test");
2301 return mark < this->my_tail && compare(this->get_my_item(0), this->get_my_item(this->my_tail - 1));
2306 if ( this->my_tail >= this->my_array_size )
2307 this->grow_my_array( this->my_tail + 1 );
2308 (
void) this->place_item(this->my_tail, src);
2310 __TBB_ASSERT(mark < this->my_tail,
"mark outside bounds after push");
2317 if (prio_use_tail()) {
2320 this->destroy_item(this->my_tail-1);
2322 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds after pop");
2325 this->destroy_item(0);
2326 if(this->my_tail > 1) {
2328 __TBB_ASSERT(this->my_item_valid(this->my_tail - 1), NULL);
2329 this->move_item(0,this->my_tail - 1);
2332 if(mark > this->my_tail) --mark;
2333 if (this->my_tail > 1)
2335 __TBB_ASSERT(mark <= this->my_tail,
"mark outside bounds after pop");
2339 return this->get_my_item(prio_use_tail() ? this->my_tail-1 : 0);
2344 if(this->my_tail == 0) {
2348 if (!mark) mark = 1;
2349 for (; mark<this->my_tail; ++mark) {
2352 this->fetch_item(mark,to_place);
2355 if (!compare(this->get_my_item(
parent), to_place))
2357 this->move_item(cur_pos,
parent);
2360 (
void) this->place_item(cur_pos, to_place);
2367 while (child < mark) {
2370 compare(this->get_my_item(child),
2371 this->get_my_item(child+1)))
2374 if (compare(this->get_my_item(target),
2375 this->get_my_item(cur_pos)))
2378 this->swap_items(cur_pos, target);
2380 child = (cur_pos<<1)+1;
2389 template<
typename T >
2396 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 2419 return ( my_count + my_tries < my_threshold && !my_predecessors.
empty() && !my_successors.
empty() );
2426 bool reserved =
false;
2429 if ( check_conditions() )
2446 if ( check_conditions() ) {
2448 task *rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
2464 if ( check_conditions() ) {
2466 task *rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
2484 if(my_count) --my_count;
2486 return forward_task();
2495 graph_node(g), my_threshold(threshold), my_count(0), my_tries(0),
2496 init_decrement_predecessors(num_decrement_predecessors),
2497 decrement(num_decrement_predecessors)
2510 my_threshold(src.my_threshold), my_count(0), my_tries(0),
2511 init_decrement_predecessors(src.init_decrement_predecessors),
2512 decrement(src.init_decrement_predecessors)
2522 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2531 bool was_empty = my_successors.
empty();
2534 if ( was_empty && !my_predecessors.
empty() && my_count + my_tries < my_threshold ) {
2536 task*
task =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
2547 r.remove_predecessor(*
this);
2552 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 2553 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
2554 built_predecessors_type &built_predecessors()
__TBB_override {
return my_predecessors.built_predecessors(); }
2556 void internal_add_built_successor(successor_type &src)
__TBB_override {
2557 my_successors.internal_add_built_successor(src);
2560 void internal_delete_built_successor(successor_type &src)
__TBB_override {
2561 my_successors.internal_delete_built_successor(src);
2564 size_t successor_count()
__TBB_override {
return my_successors.successor_count(); }
2567 my_successors.copy_successors(v);
2570 void internal_add_built_predecessor(predecessor_type &src)
__TBB_override {
2571 my_predecessors.internal_add_built_predecessor(src);
2574 void internal_delete_built_predecessor(predecessor_type &src)
__TBB_override {
2575 my_predecessors.internal_delete_built_predecessor(src);
2578 size_t predecessor_count()
__TBB_override {
return my_predecessors.predecessor_count(); }
2580 void copy_predecessors(predecessor_list_type &v)
__TBB_override {
2581 my_predecessors.copy_predecessors(v);
2586 my_successors.built_successors().sender_extract(*
this);
2587 my_predecessors.built_predecessors().receiver_extract(*
this);
2588 decrement.built_predecessors().receiver_extract(decrement);
2595 my_predecessors.
add( src );
2597 task*
task =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
2606 my_predecessors.
remove( src );
2619 if ( my_count + my_tries >= my_threshold )
2631 rtask =
new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
2654 my_predecessors.
clear();
2659 my_predecessors.
reset( );
2673 template<
typename OutputTuple,
typename JP=queueing>
class join_node;
2675 template<
typename OutputTuple>
2684 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_RESERVING, &this->my_graph,
2688 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_RESERVING, &this->my_graph,
2692 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2700 template<
typename OutputTuple>
2709 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_QUEUEING, &this->my_graph,
2713 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_QUEUEING, &this->my_graph,
2717 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2727 template<
typename OutputTuple,
typename K,
typename KHash>
2729 key_matching_port, OutputTuple, key_matching<K,KHash> > {
2737 #if __TBB_PREVIEW_MESSAGE_BASED_KEY_MATCHING 2741 template<
typename __TBB_B0,
typename __TBB_B1>
2743 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2746 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2>
2748 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2751 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3>
2753 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2756 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4>
2757 join_node(
graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4) :
2759 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2762 #if __TBB_VARIADIC_MAX >= 6 2763 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
2765 join_node(
graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5) :
2767 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2771 #if __TBB_VARIADIC_MAX >= 7 2772 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
2773 typename __TBB_B5,
typename __TBB_B6>
2774 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) :
2776 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2780 #if __TBB_VARIADIC_MAX >= 8 2781 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
2782 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7>
2783 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,
2784 __TBB_B7 b7) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7) {
2785 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2789 #if __TBB_VARIADIC_MAX >= 9 2790 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
2791 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7,
typename __TBB_B8>
2792 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,
2793 __TBB_B7 b7, __TBB_B8 b8) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8) {
2794 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2798 #if __TBB_VARIADIC_MAX >= 10 2799 template<
typename __TBB_B0,
typename __TBB_B1,
typename __TBB_B2,
typename __TBB_B3,
typename __TBB_B4,
2800 typename __TBB_B5,
typename __TBB_B6,
typename __TBB_B7,
typename __TBB_B8,
typename __TBB_B9>
2801 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,
2802 __TBB_B7 b7, __TBB_B8 b8, __TBB_B9 b9) :
unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) {
2803 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2808 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_JOIN_NODE_TAG_MATCHING, &this->my_graph,
2812 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2824 template<
typename T0,
typename T1=null_type,
typename T2=null_type,
typename T3=null_type,
2825 typename T4=null_type,
typename T5=null_type,
typename T6=null_type,
2829 template<
typename T0>
2832 static const int N = 1;
2838 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2843 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2847 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2854 template<
typename T0,
typename T1>
2857 static const int N = 2;
2863 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2868 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2872 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2879 template<
typename T0,
typename T1,
typename T2>
2882 static const int N = 3;
2888 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2893 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2897 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2904 template<
typename T0,
typename T1,
typename T2,
typename T3>
2907 static const int N = 4;
2913 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2918 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2922 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2929 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
2932 static const int N = 5;
2938 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2943 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2947 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2954 #if __TBB_VARIADIC_MAX >= 6 2955 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
2956 class indexer_node<T0, T1, T2, T3, T4, T5> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5> > {
2958 static const int N = 6;
2964 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2969 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2973 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 2979 #endif //variadic max 6 2981 #if __TBB_VARIADIC_MAX >= 7 2982 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
2984 class indexer_node<T0, T1, T2, T3, T4, T5, T6> :
public internal::unfolded_indexer_node<tuple<T0, T1, T2, T3, T4, T5, T6> > {
2986 static const int N = 7;
2992 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
2997 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3001 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3007 #endif //variadic max 7 3009 #if __TBB_VARIADIC_MAX >= 8 3010 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3011 typename T6,
typename T7>
3012 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> > {
3014 static const int N = 8;
3020 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3025 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3029 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3035 #endif //variadic max 8 3037 #if __TBB_VARIADIC_MAX >= 9 3038 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3039 typename T6,
typename T7,
typename T8>
3040 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> > {
3042 static const int N = 9;
3048 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3053 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3057 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3063 #endif //variadic max 9 3065 #if __TBB_VARIADIC_MAX >= 10 3066 template<
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
3067 typename T6,
typename T7,
typename T8,
typename T9>
3070 static const int N = 10;
3072 typedef tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
InputTuple;
3073 typedef typename internal::tagged_msg<size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> output_type;
3076 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3081 tbb::internal::fgt_multiinput_node<N>( tbb::internal::FLOW_INDEXER_NODE, &this->my_graph,
3085 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3091 #endif //variadic max 10 3093 #if __TBB_PREVIEW_ASYNC_MSG 3096 template<
typename T >
3099 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3100 s.internal_add_built_predecessor(
p);
3101 p.internal_add_built_successor(
s);
3103 p.register_successor(
s );
3108 template<
typename T >
3113 #if __TBB_PREVIEW_ASYNC_MSG 3114 template<
typename TS,
typename TR,
3121 template<
typename T >
3126 template<
typename T >
3131 #endif // __TBB_PREVIEW_ASYNC_MSG 3133 #if __TBB_FLOW_GRAPH_CPP11_FEATURES 3135 template<
typename T,
typename V,
3136 typename =
typename T::output_ports_type,
typename =
typename V::input_ports_type >
3138 make_edge(get<0>(output.output_ports()), get<0>(input.input_ports()));
3142 template<
typename T,
typename R,
3143 typename =
typename T::output_ports_type >
3145 make_edge(get<0>(output.output_ports()), input);
3149 template<
typename S,
typename V,
3150 typename =
typename V::input_ports_type >
3152 make_edge(output, get<0>(input.input_ports()));
3156 #if __TBB_PREVIEW_ASYNC_MSG 3159 template<
typename T >
3162 p.remove_successor(
s );
3163 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3165 p.internal_delete_built_successor(
s);
3166 s.internal_delete_built_predecessor(
p);
3172 template<
typename T >
3177 #if __TBB_PREVIEW_ASYNC_MSG 3178 template<
typename TS,
typename TR,
3185 template<
typename T >
3190 template<
typename T >
3194 #endif // __TBB_PREVIEW_ASYNC_MSG 3196 #if __TBB_FLOW_GRAPH_CPP11_FEATURES 3198 template<
typename T,
typename V,
3199 typename =
typename T::output_ports_type,
typename =
typename V::input_ports_type >
3201 remove_edge(get<0>(output.output_ports()), get<0>(input.input_ports()));
3205 template<
typename T,
typename R,
3206 typename =
typename T::output_ports_type >
3208 remove_edge(get<0>(output.output_ports()), input);
3211 template<
typename S,
typename V,
3212 typename =
typename V::input_ports_type >
3218 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3219 template<
typename C >
3220 template<
typename S >
3221 void internal::edge_container<C>::sender_extract(
S &
s ) {
3222 edge_list_type e = built_edges;
3223 for (
typename edge_list_type::iterator i = e.begin(); i != e.end(); ++i ) {
3228 template<
typename C >
3229 template<
typename R >
3230 void internal::edge_container<C>::receiver_extract( R &r ) {
3231 edge_list_type e = built_edges;
3232 for (
typename edge_list_type::iterator i = e.begin(); i != e.end(); ++i ) {
3239 template<
typename Body,
typename Node >
3241 return n.template copy_function_object<Body>();
3244 #if __TBB_FLOW_GRAPH_CPP11_FEATURES 3249 template<
typename... InputTypes,
typename... OutputTypes>
3260 static const size_t NUM_INPUTS =
sizeof...(InputTypes);
3261 static const size_t NUM_OUTPUTS =
sizeof...(OutputTypes);
3267 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3278 template<
typename T1,
typename T2>
3282 my_input_ports = tbb::internal::make_unique<input_ports_type>(std::forward<T1>(input_ports_tuple));
3283 my_output_ports = tbb::internal::make_unique<output_ports_type>(std::forward<T2>(output_ports_tuple));
3289 template<
typename... NodeTypes >
3292 template<
typename... NodeTypes >
3295 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3302 __TBB_ASSERT(my_input_ports,
"input ports not set, call set_external_ports to set input ports");
3303 return *my_input_ports;
3307 __TBB_ASSERT(my_output_ports,
"output ports not set, call set_external_ports to set output ports");
3308 return *my_output_ports;
3311 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3313 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
3319 template<
typename... InputTypes>
3326 static const size_t NUM_INPUTS =
sizeof...(InputTypes);
3332 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3343 template<
typename T>
3347 my_input_ports = tbb::internal::make_unique<input_ports_type>(std::forward<T>(input_ports_tuple));
3352 template<
typename... NodeTypes >
3355 template<
typename... NodeTypes >
3358 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3365 __TBB_ASSERT(my_input_ports,
"input ports not set, call set_external_ports to set input ports");
3366 return *my_input_ports;
3369 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3371 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
3378 template<
typename... OutputTypes>
3385 static const size_t NUM_OUTPUTS =
sizeof...(OutputTypes);
3391 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3402 template<
typename T>
3406 my_output_ports = tbb::internal::make_unique<output_ports_type>(std::forward<T>(output_ports_tuple));
3411 template<
typename... NodeTypes >
3414 template<
typename... NodeTypes >
3417 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3424 __TBB_ASSERT(my_output_ports,
"output ports not set, call set_external_ports to set output ports");
3425 return *my_output_ports;
3428 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3430 __TBB_ASSERT(
false,
"Current composite_node implementation does not support extract");
3436 #endif // __TBB_FLOW_GRAPH_CPP11_FEATURES 3438 namespace internal {
3440 template<
typename Gateway>
3447 my_gateway = gateway;
3454 template<
typename Input,
typename Ports,
typename Gateway,
typename Body>
3464 my_body(v, *this->my_gateway);
3476 template <
typename Input,
typename Output,
3510 my_node->my_graph.reserve_wait();
3514 my_node->my_graph.release_wait();
3520 return my_node->try_put_impl(i);
3541 template<
typename Body>
3544 tbb::internal::fgt_multioutput_node_with_body<1>( tbb::internal::FLOW_ASYNC_NODE,
3546 this->output_ports(), this->my_body );
3550 static_cast<async_body_base_type*>(this->my_body->get_body_ptr())->set_gateway(&my_gateway);
3551 static_cast<async_body_base_type*>(this->my_init_body->get_body_ptr())->set_gateway(&my_gateway);
3553 tbb::internal::fgt_multioutput_node_with_body<1>( tbb::internal::FLOW_ASYNC_NODE,
3555 this->output_ports(), this->my_body );
3562 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3572 return internal::output_port<0>(*this).register_successor(r);
3577 return internal::output_port<0>(*this).remove_successor(r);
3580 template<
typename Body>
3584 mfn_body_type &body_ref = *this->my_body;
3586 return ab.get_body();
3589 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3590 typedef typename internal::edge_container<successor_type> built_successors_type;
3592 typedef typename built_successors_type::edge_list_type successor_list_type;
3594 return internal::output_port<0>(*this).built_successors();
3597 void internal_add_built_successor( successor_type &r )
__TBB_override {
3598 internal::output_port<0>(*this).internal_add_built_successor(r);
3601 void internal_delete_built_successor( successor_type &r )
__TBB_override {
3602 internal::output_port<0>(*this).internal_delete_built_successor(r);
3606 internal::output_port<0>(*this).copy_successors(l);
3610 return internal::output_port<0>(*this).successor_count();
3617 base_type::reset_node(f);
3621 #if __TBB_PREVIEW_STREAMING_NODE 3623 #endif // __TBB_PREVIEW_STREAMING_NODE 3628 namespace interface10a {
3630 using namespace interface10;
3631 namespace internal = interface10::internal;
3633 template<
typename T >
3640 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3664 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3674 bool ret =
s.try_put( my_buffer );
3683 task *rtask =
new ( task::allocate_additional_child_of( *( my_graph.root_task() ) ) )
3700 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3701 built_predecessors_type &built_predecessors()
__TBB_override {
return my_built_predecessors; }
3702 built_successors_type &built_successors()
__TBB_override {
return my_successors.built_successors(); }
3704 void internal_add_built_successor( successor_type &
s)
__TBB_override {
3706 my_successors.internal_add_built_successor(
s);
3709 void internal_delete_built_successor( successor_type &
s)
__TBB_override {
3711 my_successors.internal_delete_built_successor(
s);
3716 return my_successors.successor_count();
3721 my_successors.copy_successors(v);
3724 void internal_add_built_predecessor( predecessor_type &
p)
__TBB_override {
3726 my_built_predecessors.add_edge(
p);
3729 void internal_delete_built_predecessor( predecessor_type &
p)
__TBB_override {
3731 my_built_predecessors.delete_edge(
p);
3736 return my_built_predecessors.edge_count();
3739 void copy_predecessors( predecessor_list_type &v )
__TBB_override {
3741 my_built_predecessors.copy_edges(v);
3745 my_buffer_is_valid =
false;
3746 built_successors().sender_extract(*
this);
3747 built_predecessors().receiver_extract(*
this);
3754 if ( my_buffer_is_valid ) {
3774 return my_buffer_is_valid;
3779 my_buffer_is_valid =
false;
3789 return try_put_task_impl(v);
3794 my_buffer_is_valid =
true;
3807 o(owner),
s(succ) {};
3810 if (!
s.register_predecessor(o)) {
3811 o.register_successor(
s);
3822 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 3823 internal::edge_container<predecessor_type> my_built_predecessors;
3830 my_buffer_is_valid =
false;
3832 my_successors.
clear();
3837 template<
typename T >
3860 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 3872 return this->my_buffer_is_valid ? NULL : this->try_put_task_impl(v);
3882 using interface10::graph;
3883 using interface10::graph_node;
3884 using interface10::continue_msg;
3886 using interface10::source_node;
3887 using interface10::function_node;
3888 using interface10::multifunction_node;
3889 using interface10::split_node;
3891 using interface10::indexer_node;
3892 using interface10::internal::tagged_msg;
3895 using interface10::continue_node;
3896 using interface10a::overwrite_node;
3897 using interface10a::write_once_node;
3898 using interface10::broadcast_node;
3899 using interface10::buffer_node;
3900 using interface10::queue_node;
3901 using interface10::sequencer_node;
3902 using interface10::priority_queue_node;
3903 using interface10::limiter_node;
3904 using namespace interface10::internal::graph_policy_namespace;
3905 using interface10::join_node;
3911 #if __TBB_FLOW_GRAPH_CPP11_FEATURES 3912 using interface10::composite_node;
3914 using interface10::async_node;
3915 #if __TBB_PREVIEW_ASYNC_MSG 3916 using interface10::async_msg;
3918 #if __TBB_PREVIEW_STREAMING_NODE 3920 using interface10::streaming_node;
3921 #endif // __TBB_PREVIEW_STREAMING_NODE 3926 #undef __TBB_PFG_RESET_ARG 3929 #endif // __TBB_flow_graph_H void add(untyped_sender &n)
static void alias_port(void *, PortsTuple &)
task * try_put_task(const T &v) __TBB_override
Put item to successor; return task to run the successor if possible.
void add_nodes(const NodeTypes &... n)
K key_from_message(const T &t)
async_body_base(gateway_type *gateway)
internal::multifunction_input< input_type, output_ports_type, Policy, Allocator > input_impl_type
internal::unfolded_indexer_node< InputTuple > unfolded_type
internal::reservable_predecessor_cache< T, spin_mutex > my_predecessors
~source_node()
The destructor.
limiter_node(const limiter_node &src)
Copy constructor.
static tbb::task * combine_tasks(graph &g, tbb::task *left, tbb::task *right)
sender< output_type >::successor_type successor_type
void register_successor(successor_type &r)
void set_ref_count(int count)
Set reference count.
untyped_sender predecessor_type
The predecessor type for this node.
split_node: accepts a tuple as input, forwards each element of the tuple to its
static task * try_put_task_wrapper_impl(receiver< T > *const this_recv, const void *p, bool is_async)
internal::unfolded_indexer_node< InputTuple > unfolded_type
graph & graph_reference() __TBB_override
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 remove_successor(successor_type &s) __TBB_override
Removes a successor from this node.
std::unique_ptr< output_ports_type > my_output_ports
void remove_edge(sender< T > &p, receiver< T > &s)
Removes an edge between a single predecessor and a single successor.
graph()
Constructs a graph with isolated task_group_context.
indexer_node(const indexer_node &other)
bool try_reserve(output_type &v)
indexer_node(const indexer_node &other)
graph & graph_reference() __TBB_override
internal::round_robin_cache< T, null_rw_mutex > my_successors
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
static void fgt_async_reserve(void *, 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 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_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
std::unique_ptr< output_ports_type > my_output_ports
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_id __itt_string_handle __itt_metadata_type type
void activate_graph(graph &g)
virtual bool try_consume()
Consumes the reserved item.
async_node(const async_node &other)
priority_queue_node(const priority_queue_node &src)
Copy constructor.
void reserve_wait() __TBB_override
Inform a graph that messages may come from outside, to prevent premature graph completion.
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
join_node(const join_node &other)
bool remove_predecessor(predecessor_type &src) __TBB_override
Removes src from the list of cached predecessors.
base_type::buffer_operation queue_operation
void reserve_wait() __TBB_override
Used to register that an external entity may still interact with the graph.
static void fgt_async_commit(void *, void *)
sender< output_type >::successor_type successor_type
const V & cast_to(T const &t)
internal::broadcast_cache< input_type > my_successors
receiver_gateway< output_type > gateway_type
Base class for user-defined tasks.
try_put_functor(output_port_type &p, const Output &v)
receiver< input_type >::predecessor_type predecessor_type
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8 > output_type
Body copy_function_object()
internal::continue_input< Output, Policy > input_impl_type
output_type my_cached_item
void reset_node(reset_flags) __TBB_override
void set_gateway(gateway_type *gateway)
internal::source_body< output_type > * my_body
receiver< input_type >::predecessor_type predecessor_type
bool register_successor(successor_type &r) __TBB_override
Add a new successor to this node.
write_once_node(const write_once_node &src)
Copy constructor: call base class copy constructor.
task * try_put_task(const T &t) __TBB_override
Puts an item to this receiver.
void __TBB_store_with_release(volatile T &location, V value)
internal::tagged_msg< size_t, T0 > output_type
Forwards messages in FIFO order.
A cache of predecessors that only supports try_get.
void const char const char int ITT_FORMAT __itt_group_sync s
graph & graph_reference() __TBB_override
join_node(const join_node &other)
interface10::internal::Policy< queueing, lightweight > queueing_lightweight
join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2)
void set_external_ports(T1 &&input_ports_tuple, T2 &&output_ports_tuple)
int init_decrement_predecessors
internal::unfolded_indexer_node< InputTuple > unfolded_type
unfolded_type::input_ports_type input_ports_type
sender< output_type >::successor_type successor_type
void internal_pop(prio_operation *op) __TBB_override
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
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::function_output< output_type > fOutput_type
bool try_release() __TBB_override
Releases the reserved item.
output_ports_type & output_ports()
receiver< input_type >::predecessor_type predecessor_type
The predecessor type for this node.
overwrite_node(const overwrite_node &src)
Copy constructor; doesn't take anything from src; default won't work.
task * try_put_task(const X &t)
bool try_put(const output_type &i)
~sequencer_node()
Destructor.
internal::async_helpers< T >::filtered_type filtered_type
priority_queue_node class_type
internal::multifunction_input< Input, typename base_type::output_ports_type, Policy, Allocator > mfn_input_type
static const T & from_void_ptr(const void *p)
sender< output_type >::successor_type successor_type
Detects whether two given types are the same.
A lock that occupies a single byte.
static void fgt_end_body(void *)
Output output_type
The type of the output message, which is complete.
indexer_node(const indexer_node &other)
virtual bool try_get(T &)
Request an item from the sender.
static void fgt_make_edge(void *, void *)
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
void set_owner(successor_type *owner)
internal::unfolded_indexer_node< InputTuple > unfolded_type
static void clear_this(P &p)
gateway_type * my_gateway
bool try_consume() __TBB_override
Consumes the reserved item.
task * try_put_task(const X &t)
async_storage_ptr my_storage
void internal_remove_edge(internal::untyped_sender &p, internal::untyped_receiver &s)
virtual bool try_release()
Releases the reserved item.
internal::async_body_base< gateway_type > async_body_base_type
receiver< input_type >::predecessor_type predecessor_type
virtual bool register_predecessor(predecessor_type &)
Add a predecessor to the node.
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
tbb::task_group_context * my_context
output_ports_type & output_ports()
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
void register_node(graph_node *n)
void increment_ref_count()
Atomically increment reference count.
reference operator *() const
Dereference.
Base class for receivers of completion messages.
internal::decrementer< limiter_node< T > > decrement
The internal receiver< continue_msg > that decrements the count.
void try_put_and_add_task(task *&last_task)
GraphNodeType & reference
An executable node that acts as a source, i.e. it has no predecessors.
Input and scheduling for a function node that takes a type Input as input.
virtual source_body * clone()=0
virtual task * try_put_task(const T &t)=0
Put item to successor; return task to run the successor if possible.
receiver< input_type >::predecessor_type predecessor_type
internal::unfolded_indexer_node< InputTuple > unfolded_type
tuple< T0, T1, T2, T3 > InputTuple
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
bool try_consume() __TBB_override
Consumes a reserved item.
limiter_node(graph &g, size_t threshold, int num_decrement_predecessors=0)
Constructor.
Implements methods for an executable node that takes continue_msg as input.
void add_nodes(const NodeTypes &... n)
virtual task * forward_task()
This is executed by an enqueued task, the "forwarder".
iterator begin()
start iterator
leaf for multifunction. OutputSet can be a std::tuple or a vector.
void remove(untyped_sender &n)
tbb::spin_mutex nodelist_mutex
Implements methods for a function node that takes a type Input as input.
bool try_release() __TBB_override
Release a reserved item.
input_impl_type::predecessor_type predecessor_type
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
async_msg< T > async_type
virtual void internal_release(buffer_operation *op)
A cache of successors that are put in a round-robin fashion.
void internal_pop(queue_operation *op) __TBB_override
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Implements methods for a function node that takes a type Input as input and sends.
tuple< T0, T1 > InputTuple
receiver< input_type >::predecessor_type predecessor_type
The base of all graph nodes.
void const char const char int ITT_FORMAT __itt_group_sync p
tuple< T0, T1, T2, T3, T4, T5, T6, T7 > InputTuple
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
internal::tagged_msg< size_t, T0, T1 > output_type
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6 > output_type
buffer_node< T, A >::size_type size_type
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7 > output_type
sender< output_type >::successor_type successor_type
void add_nodes(const NodeTypes &... n)
Forwards messages of type T to all successors.
static void * to_void_ptr(T &t)
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3)
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
input_ports_type & input_ports()
internal::function_input_queue< input_type, Allocator > input_queue_type
input_impl_type::predecessor_type predecessor_type
virtual void internal_reserve(buffer_operation *op)
Base class for types that should not be assigned.
bool register_successor(successor_type &r) __TBB_override
Replace the current successor with this new successor.
implements a function node that supports Input -> (set of outputs)
virtual void internal_pop(buffer_operation *op)
void reset_node(reset_flags f) __TBB_override
tbb::flow::tuple_element< N, typename MOP::output_ports_type >::type & output_port(MOP &op)
void internal_release(prio_operation *op) __TBB_override
void reset_node(reset_flags f) __TBB_override
int my_initial_predecessor_count
base_type::size_type size_type
buffer_node< T, A > base_type
A task that calls a node's forward_task function.
function_node(graph &g, size_t concurrency, Body body)
Constructor.
void execute_in_graph_arena(graph &g, F &f)
Executes custom functor inside graph arena.
bool try_reserve(T &v) __TBB_override
Reserves an item.
fOutput_type::successor_type successor_type
buffer_node< T, A >::buffer_operation sequencer_operation
source_node(graph &g, Body body, bool is_active=true)
Constructor for a node with a successor.
bool internal_push(prio_operation *op) __TBB_override
void make_edge(sender< T > &p, receiver< T > &s)
Makes an edge between a single predecessor and a single successor.
internal::multifunction_output< Output > output_port_type
virtual bool internal_push(buffer_operation *op)
unfolded_type::input_ports_type input_ports_type
graph_iterator< graph, graph_node > iterator
untyped_receiver successor_type
The successor type for this node.
bool try_put(const typename internal::async_helpers< T >::filtered_type &t)
Put an item to the receiver.
priority_queue_node(graph &g)
Constructor.
indexer_node(const indexer_node &other)
void reset_node(reset_flags f) __TBB_override
internal::unfolded_indexer_node< InputTuple > unfolded_type
void set_owner(owner_type *owner)
Forward declaration section.
internal::wrap_tuple_elements< N, internal::multifunction_output, Output >::type output_ports_type
task_list_type my_reset_task_list
bool try_reserve(X &t)
Reserves an item in the sender.
field of type K being used for matching.
internal::multifunction_input< input_type, output_ports_type, Policy, Allocator > base_type
buffer_node< T, A > class_type
sender< output_type >::successor_type successor_type
tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8 > InputTuple
Forwards messages in priority order.
join_node(const join_node &other)
bool register_successor(successor_type &s) __TBB_override
Add a new successor to this node.
graph & graph_reference() __TBB_override
graph_node * my_nodes_last
bool try_get(X &t)
Request an item from the sender.
receiver< input_type >::predecessor_type predecessor_type
join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4, __TBB_B5 b5)
sender< output_type >::successor_type successor_type
The type of successors of this node.
void remove_node(graph_node *n)
Represents acquisition of a mutex.
static void fgt_multioutput_node_desc(const NodeType *, const char *)
internal::unfolded_indexer_node< InputTuple > unfolded_type
continue_receiver(int number_of_predecessors=0)
Constructor.
internal::aggregating_functor< class_type, join_node_base_operation > handler_type
void deactivate_graph(graph &g)
internal::aggregating_functor< class_type, buffer_operation > handler_type
Implements an executable node that supports continue_msg -> Output.
static void fgt_reserve_wait(void *)
function_node(const function_node &src)
Copy constructor.
receiver_gateway_impl(async_node *node)
const_iterator cend() const
end const iterator
virtual bool try_reserve(T &)
Reserves an item in the sender.
receiver< input_type > receiver_type
internal::unfolded_join_node< N, key_matching_port, OutputTuple, key_matching< K, KHash > > unfolded_type
A task that calls a node's apply_body_bypass function with no input.
Body copy_body(Node &n)
Returns a copy of the body from a function or continue node.
bool try_reserve_apply_body(output_type &v)
receiver_type::predecessor_type predecessor_type
bool enqueue_forwarding_task(buffer_operation &op_data)
register_predecessor_task(predecessor_type &owner, successor_type &succ)
void internal_forward_task(queue_operation *op) __TBB_override
Tries to forward valid items to successors.
Used to form groups of tasks.
internal::broadcast_cache< output_type > & successors() __TBB_override
continue_node(graph &g, int number_of_predecessors, Body body)
Constructor for executable node with continue_msg -> Output.
Implements a function node that supports Input -> Output.
internal::aggregator< handler_type, buffer_operation > my_aggregator
internal::unfolded_indexer_node< InputTuple > unfolded_type
static void fgt_graph(void *)
sequencer_node(const sequencer_node &src)
Copy constructor.
static void fgt_async_try_put_end(void *, void *)
virtual task * execute()=0
Does whatever should happen when the threshold is reached.
internal::unfolded_join_node< N, reserving_port, OutputTuple, reserving > unfolded_type
void wait_for_all()
Wait until graph is idle and decrement_wait_count calls equals increment_wait_count calls.
void add_visible_nodes(const NodeTypes &... n)
static void fgt_composite(void *, void *)
A cache of successors that are broadcast to.
void set_external_ports(T &&output_ports_tuple)
bool try_release() __TBB_override
Release a reserved item.
void reset_node(reset_flags) __TBB_override
static void fgt_node(string_index, void *, void *)
bool is_graph_active(graph &g)
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
void internal_consume(prio_operation *op) __TBB_override
virtual ~untyped_receiver()
Destructor.
Forwards messages only if the threshold has not been reached.
void internal_forward_task(prio_operation *op) __TBB_override
Tries to forward valid items to successors.
void internal_reserve(prio_operation *op) __TBB_override
virtual void reset_node(reset_flags f=rf_reset_protocol)=0
The leaf for source_body.
tbb::flow::tuple< receiver< InputTypes > &... > input_ports_type
queue_node(graph &g)
Constructor.
sender< output_type >::successor_type successor_type
tbb::internal::uint64_t tag_value
virtual bool try_reserve_wrapper(void *p, bool is_async)=0
unfolded_join_node : passes input_ports_type to join_node_base. We build the input port type
An empty class used for messages that mean "I'm done".
buffer_node< T, A > base_type
indexer_node(const indexer_node &other)
graph_iterator< const graph, const graph_node > const_iterator
virtual graph & graph_reference()=0
virtual task * try_put_task_wrapper(const void *p, bool is_async)=0
Forwards messages in sequence order.
multifunction_node< Input, tuple< Output >, Policy, Allocator > base_type
buffer_node< T, A >::item_type item_type
task * try_put_task(const X &t)
bool try_put_impl(const Output &i)
Implements gateway_type::try_put for an external activity to submit a message to FG.
void try_put_and_add_task(task *&last_task)
Forwards messages in arbitrary order.
virtual bool try_reserve_wrapper(void *p, bool is_async) __TBB_override
indexer_node(const indexer_node &other)
Breaks an infinite loop between the node reservation and register_successor call.
tbb::flow::tuple< receiver< InputTypes > &... > input_ports_type
virtual bool try_get_wrapper(void *p, bool is_async) __TBB_override
bool try_consume() __TBB_override
Consumes a reserved item.
buffer_node< T, A >::buffer_operation prio_operation
overwrite_node< T > base_type
fOutput_type::successor_type successor_type
tbb::flow::tuple< sender< OutputTypes > &... > output_ports_type
bool try_put(const X &t)
Put an item to the receiver.
bool register_successor(successor_type &r) __TBB_override
Adds a new successor.
task * decrement_counter()
virtual ~untyped_sender()
virtual bool try_get_wrapper(void *p, bool is_async)=0
internal::tagged_msg< size_t, T0, T1, T2, T3 > output_type
buffer_node< T, A >::size_type size_type
void reset_receiver(reset_flags f) __TBB_override
put receiver back in initial state
void reset_node(reset_flags f) __TBB_override
void internal_reserve(queue_operation *op) __TBB_override
friend class proxy_dependency_receiver
void add_visible_nodes(const NodeTypes &... n)
continue_node(const continue_node &src)
Copy constructor.
indexer_node(const indexer_node &other)
void internal_consume(queue_operation *op) __TBB_override
static void fgt_node_with_body(string_index, void *, void *, void *)
An abstract cache of successors.
bool try_reserve(output_type &v) __TBB_override
Reserves an item.
static void fgt_node_desc(const NodeType *, const char *)
void release_wait() __TBB_override
Deregisters an external entity that may have interacted with the graph.
indexer_node(const indexer_node &other)
virtual bool is_continue_receiver()
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5 > output_type
internal::function_output< output_type > fOutput_type
virtual void finalize() const
Pure virtual template class that defines a receiver of messages of type T.
multifunction_node(graph &g, size_t concurrency, Body body)
item_buffer with reservable front-end. NOTE: if reserving, do not
static void fgt_release_wait(void *)
receiver< input_type >::predecessor_type predecessor_type
pointer operator->() const
Dereference.
indexer_node(const indexer_node &other)
graph & graph_reference() __TBB_override
bool try_get(output_type &v) __TBB_override
Request an item from the node.
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)
sequencer_node(graph &g, const Sequencer &s)
Constructor.
void reset_node(reset_flags f) __TBB_override
void release_wait() __TBB_override
Inform a graph that a previous call to reserve_wait is no longer in effect.
void spawn_put()
Spawns a task that applies the body.
tuple< T0, T1, T2, T3, T4, T5 > InputTuple
unfolded_type::input_ports_type input_ports_type
wrap_tuple_elements< N, PT, OutputTuple >::type input_ports_type
static void fgt_async_try_put_begin(void *, void *)
static void fgt_remove_edge(void *, void *)
sender< output_type >::successor_type successor_type
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)
buffer_node(const buffer_node &src)
Copy constructor.
internal::unfolded_indexer_node< InputTuple > unfolded_type
virtual bool register_successor(successor_type &r)=0
Add a new successor to this node.
internal::return_type_or_void< F >::type execute(F &f)
tuple< T0, T1, T2 > InputTuple
virtual void internal_reg_succ(buffer_operation *op)
Register successor.
void prio_push(const T &src)
static void fgt_graph_desc(void *, const char *)
internal::broadcast_cache< T > my_successors
void try_put_and_add_task(task *&last_task)
receiver< TupleType > base_type
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
continue_node(graph &g, Body body)
Constructor for executable node with continue_msg -> Output.
void internal_make_edge(internal::untyped_sender &p, internal::untyped_receiver &s)
continue_msg input_type
The input type.
internal::async_helpers< T >::filtered_type filtered_type
static const bool is_async_type
void reset_node(reset_flags f) __TBB_override
virtual void reset_receiver(reset_flags f=rf_reset_protocol)=0
put receiver back in initial state
bool register_successor(successor_type &r) __TBB_override
Add a new successor to this node.
void reset_node(reset_flags) __TBB_override
iterator end()
end iterator
continue_receiver(const continue_receiver &src)
Copy constructor.
void set_external_ports(T &&input_ports_tuple)
void add_task_to_graph_reset_list(graph &g, tbb::task *tp)
task * try_put_task(const input_type &) __TBB_override
Put item to successor; return task to run the successor if possible.
void fgt_multiinput_multioutput_node_desc(const NodeType *, const char *)
bool try_put(const Output &i) __TBB_override
Implements gateway_type::try_put for an external activity to submit a message to FG.
task * apply_body_bypass()
Applies the body. Returning SUCCESSFULLY_ENQUEUED okay; forward_task_bypass will handle it.
T input_type
The input type of this receiver.
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
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
void add_nodes_impl(CompositeType *, bool)
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
receiver< input_type >::predecessor_type predecessor_type
bool remove_successor(successor_type &r) __TBB_override
Removes s as a successor.
bool register_predecessor(predecessor_type &src) __TBB_override
Adds src to the list of cached predecessors.
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
void reset(reset_flags f=rf_reset_protocol)
int decrement_ref_count()
Atomically decrement reference count and returns its new value.
write_once_node(graph &g)
Constructor.
static void fgt_begin_body(void *)
const_iterator cbegin() const
start const iterator
virtual bool remove_predecessor(predecessor_type &)
Remove a predecessor from the node.
static const void * to_void_ptr(const T &t)
task * try_put_task(const input_type &v) __TBB_override
Put item to successor; return task to run the successor if possible.
tbb::flow::tuple< sender< OutputTypes > &... > output_ports_type
bool try_get(input_type &v) __TBB_override
Request an item from the sender.
internal::broadcast_cache< output_type > & successors() __TBB_override
task that does nothing. Useful for synchronization.
output_ports_type & output_ports()
void internal_forward_task_impl(buffer_operation *op, derived_type *derived)
void reset_node(reset_flags f) __TBB_override
resets the source_node to its initial state
sender< output_type >::successor_type successor_type
async_body_base< Gateway > base_type
graph & graph_reference() __TBB_override
virtual void internal_rem_succ(buffer_operation *op)
Remove successor.
split_node(const split_node &other)
tuple< T0, T1, T2, T3, T4, T5, T6 > InputTuple
queue_node(const queue_node &src)
Copy constructor.
input_ports_type & input_ports()
function_body that takes an Input and a set of output ports
tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > InputTuple
virtual task * execute()=0
Should be overridden by derived classes.
An cache of predecessors that supports requests and reservations.
successors_type my_successors
void add_visible_nodes(const NodeTypes &... n)
void reset_node(reset_flags f) __TBB_override
static void alias_port(void *, PortsTuple &)
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 * lock
void operator()(const Input &v, Ports &)
task * try_put_task(const T &t) __TBB_override
build a task to run the successor if possible. Default is old behavior.
tuple< T0, T1, T2, T3, T4 > InputTuple
internal::unfolded_indexer_node< InputTuple > unfolded_type
void remove_successor(successor_type &r)
graph_iterator()
Default constructor.
broadcast_node(const broadcast_node &src)
A functor that spawns a task.
void reset_node(reset_flags f) __TBB_override
virtual void handle_operations(buffer_operation *op_list)
bool internal_push(sequencer_operation *op) __TBB_override
task * try_put_task_impl(const input_type &v)
~graph()
Destroys the graph.
tbb::task_arena * my_task_arena
internal::function_input< input_type, output_type, Policy, Allocator > input_impl_type
static void fgt_multiinput_multioutput_node(string_index, void *, void *)
source_node(const source_node &src)
Copy constructor.
async_body(const Body &body, gateway_type *gateway)
async_node(graph &g, size_t concurrency, Body body)
internal::port_ref_impl< N1, N2 > port_ref()
bool remove_successor(successor_type &r) __TBB_override
Removes a successor.
std::unique_ptr< input_ports_type > my_input_ports
internal::tagged_msg< size_t, T0, T1, T2, T3, T4 > output_type
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
internal::function_input_queue< input_type, Allocator > input_queue_type
static tbb::task *const SUCCESSFULLY_ENQUEUED
internal::unfolded_join_node< N, queueing_port, OutputTuple, queueing > unfolded_type
static const void * to_void_ptr(const T &t)
bool is_continue_receiver() __TBB_override
internal::tagged_msg< size_t, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > output_type
void handle_operations(prio_operation *op_list) __TBB_override
task * try_put_task(const T &t) __TBB_override
receive an item, return a task *if possible
base_type::output_ports_type output_ports_type
void prepare_task_arena(bool reinit=false)
Implements methods for both executable and function nodes that puts Output to its successors.
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
bool try_reserve(T &v) __TBB_override
Reserves an item.
void reset_receiver(reset_flags) __TBB_override
put receiver back in initial state
bool register_predecessor(predecessor_type &) __TBB_override
Increments the trigger threshold.
static task * emit_this(graph &g, const T &t, P &p)
virtual bool remove_successor(successor_type &r)=0
Removes a successor from this node.
bool register_successor(successor_type &r) __TBB_override
Adds a successor.
join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1)
T output_type
The output type of this sender.
internal::function_body< T, size_t > * my_sequencer
Enables one or the other code branches.
virtual task * try_put_task_wrapper(const void *p, bool is_async) __TBB_override
internal::wrap_tuple_elements< N, internal::multifunction_output, TupleType >::type output_ports_type
internal::tagged_msg< size_t, T0, T1, T2 > output_type
#define __TBB_STATIC_ASSERT(condition, msg)
Body copy_function_object()
std::unique_ptr< input_ports_type > my_input_ports
join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, __TBB_B4 b4)
bool remove_predecessor(predecessor_type &) __TBB_override
Decrements the trigger threshold.
concurrency
An enumeration the provides the two most common concurrency levels: unlimited and serial.
bool try_get(T &v) __TBB_override
Request an item from the buffer_node.
indexer_node(const indexer_node &other)
bool remove_successor(successor_type &r) __TBB_override
Removes a successor from this node.
multifunction_node(const multifunction_node &other)
output_ports_type my_output_ports