input_node#
[flow_graph.input_node]
A node that generates messages by invoking the user-provided functor and broadcasts the result to all of its successors.
// Defined in header <oneapi/tbb/flow_graph.h>
namespace oneapi {
namespace tbb {
namespace flow {
    template < typename Output >
    class input_node : public graph_node, public sender<Output> {
    public:
        template< typename Body >
        input_node( graph &g, Body body );
        input_node( const input_node &src );
        ~input_node();
        void activate();
        bool try_get( Output &v );
    };
} // namespace flow
} // namespace tbb
} // namespace oneapi
Requirements:
The
Outputtype must meet the DefaultConstructible requirements from [defaultconstructible], CopyConstructible requirements from [copyconstructible] and CopyAssignable requirements from [copyassignable] ISO C++ Standard sections.The type
Bodymust meet the InputNodeBody requirements.
This node can have no predecessors. It executes a user-provided body function object to
generate messages that are broadcast to all successors. It is a serial node and never calls
its body concurrently. This node can buffer a single item.  If no successor accepts an
item that it has generated, the message is buffered and provided to successors
before a new item is generated.
input_node is a graph_node and sender<Output>.
input_node has a buffering and broadcast-push properties.
An input_node continues to invoke body and broadcast messages until the body
toggles fc.stop() or it has no valid successors. A message may be generated and then rejected
by all successors. In this case, the message is buffered and will be the next message sent once a
successor is added to the node or try_get is called. Calls to try_get return a
message from the buffer, or invoke body to attempt to generate a new message.
A call to body is made only when the buffer is empty.
The body object passed to an input_node is copied. Updates to member variables do
not affect the original object used to construct the node. If the state held within a body object
must be inspected from outside of the node, the copy_body function can be
used to obtain an updated copy.
Member functions#
- 
template<typename Body>
input_node(graph &g, Body body)# Constructs an
input_nodethat invokesbody. By default, the node is created in an inactive state, which means that messages are not generated until a call toactivateis made.
- 
input_node(const input_node &src)#
 Constructs an
input_nodethat has the same initial state thatsrchad when it was constructed. Theinput_nodethat is constructed has a reference to the samegraphobject assrc, has a copy of the initial body used bysrc,and has the same initial active state assrc. The successors ofsrcare not copied.The new body object is copy-constructed from a copy of the original body provided to
srcat its construction. Changes made to member variables insrcbody after the construction ofsrcdo not affect the body of the newinput_node.
- 
void activate()#
 Sets the
input_nodeto the active state, which enables messages generation.
- 
bool try_get(Output &v)#
 Copies the message from the buffer to
vif available, or, if the node is in active state, invokesbodyto attempt to generate a new message that will be copied intov.Returns:
trueif a message is copied tov;false, otherwise.
Deduction Guides#
template <typename Body>
input_node(graph&, Body) -> input_node<std::decay_t<input_t<Body>>>;
Where:
input_tis an alias toBodyinput argument type.