I want to use oneTBB to write such a node, that can receive a value, and then generate a vector of int. But instead of sending the vector as a single output, I want to send each vector element as a single message, so they can be processed by individual successors. After finishing sending all elements, then start to receive next input message. I don't think multifunction_node that publishes std::tuple is design for this purpose. Anyone could give me some suggestions? thank you!
Asked
Active
Viewed 161 times
0
-
Please provide enough code so others can better understand or reproduce the problem. – Community Oct 06 '22 at 10:49
1 Answers
0
Multifunction_node is still useful here, because this is the type of the node that allows sending zero or more messages to each of its successors. The successors input type is specified as a single tuple element of the multifunction node's output. Thus, if accepting an int
and sending of multiple ints
to single successor is desired then use multifunction_node<int, std::tuple<int>>
. Since it is important that new message does not arrive while the current one is being processed, the node should have serial
concurrency.
So, the result node declaration might look like the following in your code:
using mf_node_type = tbb::flow::multifunction_node<int, std::tuple<int>>;
mf_node_type mf(
graph_reference, tbb::flow::serial,
[output_vector_size](int message, mf_node_type::output_ports_type& p) {
for (int i = 0; i < output_vector_size; ++i) {
int message_to_successor = i;
std::get<0>(p).try_put(message_to_successor);
}
});

Aleksei Fedotov
- 395
- 1
- 9