Policy for functional nodes helps to reduce the overhead associated with the execution scheduling of the node. This policy should only be applied on a per-node basis after careful evaluation.
#define TBB_PREVIEW_FLOW_GRAPH_LIGHTWEIGHT 1 #include "tbb/flow_graph.h"
The lightweight policy indicates that the body of the node contains a small amount of work and should, if possible, be executed without the overhead of scheduling a task. All Flow Graph functional nodes, except for source_node, support the lightweight policy as a possible value of the Policy template parameter. To use the lightweight policy, specify the Policy template parameter of the node to queueing_lightweight, rejecting_lightweight, or lightweight. If you specify Policy to lightweight, the node will have queueing buffering policy.
Use of lightweight policy for a function_node with serial execution semantics can change the order of passing messages to node's successors. If the message passing order is important, you should use sequencer_node after the nodes that have the lightweight policy.
Having multiple successors with lightweight policy for a particular node can significantly reduce the parallelism available in the graph.