Search code examples
c++multithreadingtbbtbb-flow-graph

Async input/output and non-uniform output from TBB nodes


I am at the very start of a project where I plan to use the Intel Threading Building Block library in particular the Flow Graph part.

In that respect I have two questions:

  1. Is it possible to have nodes that have asynchronous input/output relations? For example, a special buffer node that will take some data input, and provide some output sporadically (e.g. computed stats)

  2. Is it possible to have nodes that sends different messages to succeeding nodes? Not a simple broadcast in other words.


Solution

  • Tor,

    In both cases the node you want is a multifunction_node. The node will receive inputs like a regular function_node, and it has a tuple of output ports you can attach to (you can make the tuple have one element.)

    The node receives messages but the action it takes does not necessarily require an output message.

    I am not sure in the second point if you are asking about sending messages to different nodes, or if you are sending different types of messages to the same node. If it is the latter, you could use std::variant.