Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2478 Discussions

How to custom copy function of TBB flowgraph's broadcast_node

Ds_Good
Beginner
218 Views

How can I use the broadcast_node of TBB to customize the copying of node data? Since my data is quite large and encapsulated with std::shared_ptr, now I need to automatically complete the customized copying when the broadcast_node outputs. How should I achieve this?

0 Kudos
1 Reply
digixvalley
Beginner
159 Views

To customize the copying behavior in TBB's broadcast_node, you can use a function_node to apply custom logic to each message before it reaches the broadcast stage:

Steps:

  1. Create a Custom Node: Use a function_node to process or modify messages as needed (e.g., apply a custom copy or transformation). This node will handle any pre-broadcast customization.
  2. Connect to Broadcast: Link the function_node to a broadcast_node, which will then distribute the modified message to all connected receivers.

Example Workflow:

  • The custom node processes each message, performing the desired customization (e.g., doubling the value or applying a specific transformation).
  • The broadcast node receives the modified message from the custom node and forwards it to multiple receiver nodes.
  • Receiver nodes then process the final message.

This approach gives you flexibility in how each message is copied or transformed before being sent to multiple destinations.

0 Kudos
Reply