continue_node to count messages from single predecessor

continue_node to count messages from single predecessor

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);
T==2?

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

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

Thanks,
Igor

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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,
Chris

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

Igor

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui