Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
tbb::flow::interface11::input_node< Output > Class Template Reference

An executable node that acts as a source, i.e. it has no predecessors. More...

#include <flow_graph.h>

Inheritance diagram for tbb::flow::interface11::input_node< Output >:
Collaboration diagram for tbb::flow::interface11::input_node< Output >:

Public Types

typedef Output output_type
 The type of the output message, which is complete. More...
 
typedef sender< output_type >::successor_type successor_type
 The type of successors of this node. More...
 
typedef null_type input_type
 
- Public Types inherited from tbb::flow::interface11::internal::untyped_sender
typedef untyped_receiver successor_type
 The successor type for this node. More...
 

Public Member Functions

template<typename Body >
__TBB_NOINLINE_SYM input_node (graph &g, Body body)
 Constructor for a node with a successor. More...
 
__TBB_NOINLINE_SYM input_node (const input_node &src)
 Copy constructor. More...
 
 ~input_node ()
 The destructor. More...
 
bool register_successor (successor_type &r) __TBB_override
 Add a new successor to this node. More...
 
bool remove_successor (successor_type &r) __TBB_override
 Removes a successor from this node. More...
 
bool try_get (output_type &v) __TBB_override
 Request an item from the node. More...
 
bool try_reserve (output_type &v) __TBB_override
 Reserves an item. More...
 
bool try_release () __TBB_override
 Release a reserved item. More...
 
bool try_consume () __TBB_override
 Consumes a reserved item. More...
 
void activate ()
 Activates a node that was created in the inactive state. More...
 
template<typename Body >
Body copy_function_object ()
 
- Public Member Functions inherited from tbb::flow::interface11::graph_node
 graph_node (graph &g)
 
virtual ~graph_node ()
 
virtual bool try_get (Output &)
 Request an item from the sender. More...
 
virtual bool try_reserve (Output &)
 Reserves an item in the sender. More...
 
- Public Member Functions inherited from tbb::flow::interface11::internal::untyped_sender
virtual ~untyped_sender ()
 
virtual bool register_successor (successor_type &r)=0
 Add a new successor to this node. More...
 
virtual bool remove_successor (successor_type &r)=0
 Removes a successor from this node. More...
 
virtual bool try_release ()
 Releases the reserved item. More...
 
virtual bool try_consume ()
 Consumes the reserved item. More...
 

Protected Member Functions

void reset_node (reset_flags f) __TBB_override
 resets the source_node to its initial state More...
 
virtual void reset_node (reset_flags f=rf_reset_protocol)=0
 
- Protected Member Functions inherited from tbb::flow::interface11::sender< Output >
virtual bool try_get_wrapper (void *p, bool is_async) __TBB_override
 
virtual bool try_reserve_wrapper (void *p, bool is_async) __TBB_override
 
- Protected Member Functions inherited from tbb::flow::interface11::internal::untyped_sender
template<typename X >
bool try_get (X &t)
 Request an item from the sender. More...
 
template<typename X >
bool try_reserve (X &t)
 Reserves an item in the sender. More...
 
virtual bool try_get_wrapper (void *p, bool is_async)=0
 
virtual bool try_reserve_wrapper (void *p, bool is_async)=0
 

Private Member Functions

bool try_reserve_apply_body (output_type &v)
 
taskcreate_put_task ()
 
void spawn_put ()
 Spawns a task that applies the body. More...
 
taskapply_body_bypass ()
 Applies the body. Returning SUCCESSFULLY_ENQUEUED okay; forward_task_bypass will handle it. More...
 

Private Attributes

spin_mutex my_mutex
 
bool my_active
 
internal::source_body< output_type > * my_body
 
internal::source_body< output_type > * my_init_body
 
internal::broadcast_cache< output_typemy_successors
 
bool my_reserved
 
bool my_has_cached_item
 
output_type my_cached_item
 

Friends

class internal::source_task_bypass< input_node< output_type > >
 

Additional Inherited Members

- Public Attributes inherited from tbb::flow::interface11::sender< Output >
__TBB_DEPRECATED typedef Output output_type
 The output type of this sender. More...
 
__TBB_DEPRECATED typedef internal::async_helpers< Output >::filtered_type filtered_type
 
- Protected Attributes inherited from tbb::flow::interface11::graph_node
graphmy_graph
 
graph_nodenext
 
graph_nodeprev
 

Detailed Description

template<typename Output>
class tbb::flow::interface11::input_node< Output >

An executable node that acts as a source, i.e. it has no predecessors.

Definition at line 903 of file flow_graph.h.

Member Typedef Documentation

◆ input_type

template<typename Output >
typedef null_type tbb::flow::interface11::input_node< Output >::input_type

Definition at line 912 of file flow_graph.h.

◆ output_type

template<typename Output >
typedef Output tbb::flow::interface11::input_node< Output >::output_type

The type of the output message, which is complete.

Definition at line 906 of file flow_graph.h.

◆ successor_type

template<typename Output >
typedef sender<output_type>::successor_type tbb::flow::interface11::input_node< Output >::successor_type

The type of successors of this node.

Definition at line 909 of file flow_graph.h.

Constructor & Destructor Documentation

◆ input_node() [1/2]

template<typename Output >
template<typename Body >
__TBB_NOINLINE_SYM tbb::flow::interface11::input_node< Output >::input_node ( graph g,
Body  body 
)
inline

Constructor for a node with a successor.

Definition at line 921 of file flow_graph.h.

922 : graph_node(g), my_active(false),
925 my_reserved(false), my_has_cached_item(false)
926 {
927 my_successors.set_owner(this);
928 tbb::internal::fgt_node_with_body( CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
929 static_cast<sender<output_type> *>(this), this->my_body );
930 }
#define CODEPTR()
static void fgt_node_with_body(void *, string_index, void *, void *, void *)
internal::source_body< output_type > * my_body
Definition: flow_graph.h:1101
internal::broadcast_cache< output_type > my_successors
Definition: flow_graph.h:1103
internal::source_body< output_type > * my_init_body
Definition: flow_graph.h:1102
The leaf for source_body.

References CODEPTR, tbb::internal::fgt_node_with_body(), tbb::flow::interface11::input_node< Output >::my_body, tbb::flow::interface11::graph_node::my_graph, and tbb::flow::interface11::input_node< Output >::my_successors.

Here is the call graph for this function:

◆ input_node() [2/2]

template<typename Output >
__TBB_NOINLINE_SYM tbb::flow::interface11::input_node< Output >::input_node ( const input_node< Output > &  src)
inline

Copy constructor.

Definition at line 941 of file flow_graph.h.

941 :
942 graph_node(src.my_graph), sender<Output>(),
943 my_active(false),
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)
946 {
947 my_successors.set_owner(this);
948 tbb::internal::fgt_node_with_body(CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
949 static_cast<sender<output_type> *>(this), this->my_body );
950 }

References CODEPTR, tbb::internal::fgt_node_with_body(), tbb::flow::interface11::input_node< Output >::my_body, tbb::flow::interface11::graph_node::my_graph, and tbb::flow::interface11::input_node< Output >::my_successors.

Here is the call graph for this function:

◆ ~input_node()

template<typename Output >
tbb::flow::interface11::input_node< Output >::~input_node ( )
inline

Member Function Documentation

◆ activate()

template<typename Output >
void tbb::flow::interface11::input_node< Output >::activate ( )
inline

Activates a node that was created in the inactive state.

Definition at line 1060 of file flow_graph.h.

1060 {
1062 my_active = true;
1063 if (!my_successors.empty())
1064 spawn_put();
1065 }
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 spawn_put()
Spawns a task that applies the body.
Definition: flow_graph.h:1137
friend class scoped_lock
Definition: spin_mutex.h:179

References lock, tbb::flow::interface11::input_node< Output >::my_active, tbb::flow::interface11::input_node< Output >::my_mutex, tbb::flow::interface11::input_node< Output >::my_successors, and tbb::flow::interface11::input_node< Output >::spawn_put().

Here is the call graph for this function:

◆ apply_body_bypass()

template<typename Output >
task * tbb::flow::interface11::input_node< Output >::apply_body_bypass ( )
inlineprivate

Applies the body. Returning SUCCESSFULLY_ENQUEUED okay; forward_task_bypass will handle it.

Definition at line 1145 of file flow_graph.h.

1145 {
1146 output_type v;
1147 if ( !try_reserve_apply_body(v) )
1148 return NULL;
1149
1150 task *last_task = my_successors.try_put_task(v);
1151 if ( last_task )
1152 try_consume();
1153 else
1154 try_release();
1155 return last_task;
1156 }
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 * task
bool try_release() __TBB_override
Release a reserved item.
Definition: flow_graph.h:1038
bool try_reserve_apply_body(output_type &v)
Definition: flow_graph.h:1109
Output output_type
The type of the output message, which is complete.
Definition: flow_graph.h:906
bool try_consume() __TBB_override
Consumes a reserved item.
Definition: flow_graph.h:1048

References tbb::flow::interface11::input_node< Output >::my_successors, tbb::flow::interface11::input_node< Output >::try_consume(), tbb::flow::interface11::input_node< Output >::try_release(), and tbb::flow::interface11::input_node< Output >::try_reserve_apply_body().

Here is the call graph for this function:

◆ copy_function_object()

template<typename Output >
template<typename Body >
Body tbb::flow::interface11::input_node< Output >::copy_function_object ( )
inline

Definition at line 1068 of file flow_graph.h.

1068 {
1070 return dynamic_cast< internal::source_body_leaf<output_type, Body> & >(body_ref).get_body();
1071 }

References tbb::flow::interface11::input_node< Output >::my_body.

◆ create_put_task()

template<typename Output >
task * tbb::flow::interface11::input_node< Output >::create_put_task ( )
inlineprivate

Definition at line 1131 of file flow_graph.h.

1131 {
1132 return ( new ( task::allocate_additional_child_of( *(this->my_graph.root_task()) ) )
1133 internal:: source_task_bypass < input_node< output_type > >( *this ) );
1134 }
A task that calls a node's apply_body_bypass function with no input.
tbb::task * root_task()
Returns the root task of the graph.

References tbb::flow::interface11::graph_node::my_graph, and tbb::flow::interface10::graph::root_task().

Here is the call graph for this function:

◆ register_successor()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::register_successor ( successor_type r)
inlinevirtual

◆ remove_successor()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::remove_successor ( successor_type r)
inlinevirtual

Removes a successor from this node.

Implements tbb::flow::interface11::internal::untyped_sender.

Definition at line 971 of file flow_graph.h.

971 {
973 my_successors.remove_successor(r);
974 return true;
975 }

References lock, tbb::flow::interface11::input_node< Output >::my_mutex, and tbb::flow::interface11::input_node< Output >::my_successors.

◆ reset_node()

◆ spawn_put()

template<typename Output >
void tbb::flow::interface11::input_node< Output >::spawn_put ( )
inlineprivate

Spawns a task that applies the body.

Definition at line 1137 of file flow_graph.h.

1137 {
1140 }
1141 }
void spawn_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
bool is_graph_active(tbb::flow::interface10::graph &g)

Referenced by tbb::flow::interface11::input_node< Output >::activate(), tbb::flow::interface11::input_node< Output >::register_successor(), tbb::flow::interface11::input_node< Output >::try_consume(), tbb::flow::interface11::input_node< Output >::try_get(), and tbb::flow::interface11::input_node< Output >::try_release().

Here is the caller graph for this function:

◆ try_consume()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::try_consume ( )
inlinevirtual

Consumes a reserved item.

Reimplemented from tbb::flow::interface11::internal::untyped_sender.

Definition at line 1048 of file flow_graph.h.

1048 {
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() ) {
1054 spawn_put();
1055 }
1056 return true;
1057 }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT, lock, tbb::flow::interface11::input_node< Output >::my_has_cached_item, tbb::flow::interface11::input_node< Output >::my_mutex, tbb::flow::interface11::input_node< Output >::my_reserved, tbb::flow::interface11::input_node< Output >::my_successors, and tbb::flow::interface11::input_node< Output >::spawn_put().

Referenced by tbb::flow::interface11::input_node< Output >::apply_body_bypass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_get()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::try_get ( output_type v)
inlinevirtual

Request an item from the node.

Reimplemented from tbb::flow::interface11::sender< Output >.

Definition at line 1003 of file flow_graph.h.

1003 {
1005 if ( my_reserved )
1006 return false;
1007
1008 if ( my_has_cached_item ) {
1009 v = my_cached_item;
1010 my_has_cached_item = false;
1011 return true;
1012 }
1013 // we've been asked to provide an item, but we have none. enqueue a task to
1014 // provide one.
1015 if ( my_active )
1016 spawn_put();
1017 return false;
1018 }

References lock, tbb::flow::interface11::input_node< Output >::my_active, tbb::flow::interface11::input_node< Output >::my_cached_item, tbb::flow::interface11::input_node< Output >::my_has_cached_item, tbb::flow::interface11::input_node< Output >::my_mutex, tbb::flow::interface11::input_node< Output >::my_reserved, and tbb::flow::interface11::input_node< Output >::spawn_put().

Here is the call graph for this function:

◆ try_release()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::try_release ( )
inlinevirtual

Release a reserved item.

true = item has been released and so remains in sender, dest must request or reserve future items

Reimplemented from tbb::flow::interface11::internal::untyped_sender.

Definition at line 1038 of file flow_graph.h.

1038 {
1040 __TBB_ASSERT( my_reserved && my_has_cached_item, "releasing non-existent reservation" );
1041 my_reserved = false;
1042 if(!my_successors.empty())
1043 spawn_put();
1044 return true;
1045 }

References __TBB_ASSERT, lock, tbb::flow::interface11::input_node< Output >::my_has_cached_item, tbb::flow::interface11::input_node< Output >::my_mutex, tbb::flow::interface11::input_node< Output >::my_reserved, tbb::flow::interface11::input_node< Output >::my_successors, and tbb::flow::interface11::input_node< Output >::spawn_put().

Referenced by tbb::flow::interface11::input_node< Output >::apply_body_bypass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_reserve()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::try_reserve ( output_type v)
inlinevirtual

Reserves an item.

Reimplemented from tbb::flow::interface11::sender< Output >.

Definition at line 1021 of file flow_graph.h.

1021 {
1023 if ( my_reserved ) {
1024 return false;
1025 }
1026
1027 if ( my_has_cached_item ) {
1028 v = my_cached_item;
1029 my_reserved = true;
1030 return true;
1031 } else {
1032 return false;
1033 }
1034 }

References lock, tbb::flow::interface11::input_node< Output >::my_cached_item, tbb::flow::interface11::input_node< Output >::my_has_cached_item, tbb::flow::interface11::input_node< Output >::my_mutex, and tbb::flow::interface11::input_node< Output >::my_reserved.

◆ try_reserve_apply_body()

template<typename Output >
bool tbb::flow::interface11::input_node< Output >::try_reserve_apply_body ( output_type v)
inlineprivate

Definition at line 1109 of file flow_graph.h.

1109 {
1111 if ( my_reserved ) {
1112 return false;
1113 }
1114 if ( !my_has_cached_item ) {
1116 bool r = (*my_body)(my_cached_item);
1118 if (r) {
1119 my_has_cached_item = true;
1120 }
1121 }
1122 if ( my_has_cached_item ) {
1123 v = my_cached_item;
1124 my_reserved = true;
1125 return true;
1126 } else {
1127 return false;
1128 }
1129 }
static void fgt_begin_body(void *)
static void fgt_end_body(void *)

References tbb::internal::fgt_begin_body(), tbb::internal::fgt_end_body(), lock, tbb::flow::interface11::input_node< Output >::my_body, tbb::flow::interface11::input_node< Output >::my_cached_item, tbb::flow::interface11::input_node< Output >::my_has_cached_item, tbb::flow::interface11::input_node< Output >::my_mutex, and tbb::flow::interface11::input_node< Output >::my_reserved.

Referenced by tbb::flow::interface11::input_node< Output >::apply_body_bypass().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ internal::source_task_bypass< input_node< output_type > >

template<typename Output >
friend class internal::source_task_bypass< input_node< output_type > >
friend

Definition at line 1137 of file flow_graph.h.

Member Data Documentation

◆ my_active

◆ my_body

◆ my_cached_item

◆ my_has_cached_item

◆ my_init_body

◆ my_mutex

◆ my_reserved

◆ my_successors


The documentation for this class was generated from the following file:

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.