continue_node

[flow_graph.continue_node]

A node that executes a specified body object when triggered.

// Defined in header <tbb/flow_graph.h>

namespace tbb {
namespace flow {

    template< typename Output, typename Policy = /*implementation-defined*/ >
    class continue_node : public graph_node, public receiver<continue_msg>, public sender<Output> {
    public:
        template<typename Body>
        continue_node( graph &g, Body body, node_priority_t priority = no_priority );
        template<typename Body>
        continue_node( graph &g, Body body, Policy /*unspecified*/ = Policy(),
                      node_priority_t priority = no_priority );

        template<typename Body>
        continue_node( graph &g, int number_of_predecessors, Body body,
                       node_priority_t priority = no_priority );
        template<typename Body>
        continue_node( graph &g, int number_of_predecessors, Body body,
                       Policy /*unspecified*/ = Policy(), node_priority_t priority = no_priority );

        continue_node( const continue_node &src );
        ~continue_node();

        bool try_put( const input_type &v );
        bool try_get( output_type &v );
    };

} // namespace flow
} // namespace tbb

Requirements:

  • The type Output must meet the CopyConstructible requirements from [copyconstructible] ISO C++ Standard section.

  • The type Policy can be specified as lightweight policy or defaulted.

  • The type Body must meet the ContinueNodeBody requirements.

A continue_node is a graph_node, receiver<continue_msg>, and sender<Output>.

This node is used for nodes that wait for their predecessors to complete before executing, but no explicit data is passed across the incoming edges.

A continue_node maintains an internal threshold that defines the number of predecessors. This value can be provided at construction. Call of the make_edge function with continue_node as a receiver increases its threshold. Call of the remove_edge function with continue_node as a receiver decreases it.

Each time the number of try_put() calls reaches the defined threshold, node’s body is called and the node starts counting the number of try_put() calls from the beginning.

continue_node has a discarding and broadcast-push properties.

The body object passed to a continue_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>
continue_node( graph &g, Body body, node_priority_t priority = no_priority );

Constructs a continue_node that invokes body. The internal threshold is set to 0.

This function specifies node priority.


template<typename Body>
continue_node( graph &g, Body body, Policy /*unspecified*/ = Policy(),
               node_priority_t priority = no_priority );

Constructs a continue_node that invokes body. The internal threshold is set to 0.

This function specifies lightweight policy and node priority.


template<typename Body>
continue_node( graph &g, int number_of_predecessors, Body body,
               node_priority_t priority = no_priority );

Constructs a continue_node that invokes body. The internal threshold is set to number_of_predecessors.

This function specifies node priority.


template<typename Body>
continue_node( graph &g, int number_of_predecessors, Body body,
               Policy /*unspecified*/ = Policy(), node_priority_t priority = no_priority );

Constructs a continue_node that invokes body. The internal threshold is set to number_of_predecessors.

This function specifies lightweight policy and node priority.


template<typename Body>
continue_node( graph &g, int number_of_predecessors, Body body );

Constructs a continue_node that invokes body. The internal threshold is set to number_of_predecessors.


continue_node( const continue_node &src )

Constructs a continue_node that has the same initial state that src had after its construction. It does not copy the current count of try_puts received, or the current known number of predecessors. The continue_node that is constructed has a reference to the same graph object as src, has a copy of the initial body used by src, and only has a non-zero threshold if src is constructed with a non-zero threshold.

The new body object is copy-constructed from a copy of the original body provided to src at its construction.


bool try_put( const Input &v )

Increments the count of try_put() calls received. If the incremented count is equal to the number of known predecessors, performs the body function object execution. It does not wait for the execution of the body to complete.

Returns: true


bool try_get( Output &v )

Returns: false

Deduction Guides

template <typename Body, typename Policy>
continue_node(graph&, Body, Policy, node_priority_t = no_priority)
    -> continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>, Policy>;

template <typename Body, typename Policy>
continue_node(graph&, int, Body, Policy, node_priority_t = no_priority)
    -> continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>, Policy>;

template <typename Body>
continue_node(graph&, Body, node_priority_t = no_priority)
    -> continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>, /*default-policy*/>;

template <typename Body>
continue_node(graph&, int, Body, node_priority_t = no_priority)
    -> continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>, /*default-policy*/>;

Where:

  • continue_output_t<Output> is an alias to Output template argument type. If Output specified as void, continue_output_t<Output> is an alias to continue_msg type.

Example

A set of continue_nodes forms a Dependency Flow Graph.