Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
2417 Discussions

continue_node to count messages from single predecessor

New Contributor I

I'm trying to make a counting_node out of the continue_node.

I'm not sure I understand the documentation of the continue_node regaring the value of the internal threshold, T. If I provide a value in constructor, would it still be incremented as I add a predecessor? Also, is it okay to want to have T=2 and only one predecessor? For example, in the code below what is the value of T?

continue_node<continue_msg> count2(g, 1, MessageForward());
make_edge(some_message_generator, count2);

Also, is there a predefined simple message forwarder body as follows?

class MessageForward {
    continue_msg operator()(continue_msg /*m*/) {
        return continue_msg();


0 Kudos
2 Replies

Hello, Igor,

Sorry I didn't respond earlier.  Yes, I've also noticed the documentation should be improved.  The continue_node's internal threshold tells how many continue_msg()s are received before the body of the node is executed, but the node doesn't care which predecessors send it a message.  The threshold is incremented when edge is added from a predecessor, and decremented when an edge is removed.

So if you specify 1 as the initial value for the threshold (somewhat misleadingly-named number_of_predecessors), then add one edge from another node to the continue_node, the node will execute its body after every second continue_msg() received.

If the number_of_predecessors is 0, and you add edges from two nodes to the continue_node, after receiving two continue_msg()s from either of the nodes (in any combination) the continue_node will execute its body and attempt to forward the message.  It doesn't require the messages to come from any particular node.

There is no predefined body for the continue_node.

Best Regards,

New Contributor I

Thank you Chris, continue_node works as you described. This way I can decimate the messages flowing through the graph.