Skip to content

Commit e3ff139

Browse files
[oneTBB] Clarify lightweight policy requirements (#407)
* Clarify lightweight policy requirements * Improve wording for the lightweight policies Signed-off-by: Fedotov, Aleksei <[email protected]> Co-authored-by: Alexey Kukanov <[email protected]>
1 parent 3400ab8 commit e3ff139

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

source/elements/oneTBB/source/flow_graph/examples/lightweight_policy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ int main() {
88
function_node< int, int > add( g, unlimited, [](const int &v) {
99
return v+1;
1010
} );
11-
function_node< int, int, lightweight > multiply( g, unlimited, [](const int &v) {
11+
function_node< int, int, lightweight > multiply( g, unlimited, [](const int &v) noexcept {
1212
return v*2;
1313
} );
14-
function_node< int, int, lightweight > cube( g, unlimited, [](const int &v) {
14+
function_node< int, int, lightweight > cube( g, unlimited, [](const int &v) noexcept {
1515
return v*v*v;
1616
} );
1717

source/elements/oneTBB/source/flow_graph/functional_node_policies.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ of a predecessor to handle this.
4848
Lightweight
4949
-----------
5050

51-
This policy helps to reduce the overhead associated with the execution scheduling of the node.
51+
This policy allows to specify that the node body takes little time to process, as a non-binding hint
52+
for an implementation to reduce overheads associated with the node execution. Any optimization applied
53+
by an implementation must have no observable side effects on the node and graph execution.
5254

53-
For functional nodes that have a default value for the ``Policy`` template parameter, specifying
54-
the ``lightweight`` policy results in extending the behavior of the default value of ``Policy``
55-
with the behavior defined by the ``lightweight`` policy. For example, if the default value of
55+
When combined with another policy, the ``lightweight`` policy results in extending the behavior
56+
of that other policy with the optimization hint. This rule automatically applies to functional nodes
57+
that have a default value for the ``Policy`` template parameter. For example, if the default value of
5658
``Policy`` is ``queueing``, specifying ``lightweight`` as the ``Policy`` value is equivalent to
5759
specifying ``queueing_lightweight``.
5860

61+
The function call ``operator()`` of a node body must be ``noexcept`` for lightweight policies to have effect.
62+
5963
Example
6064
~~~~~~~
6165

0 commit comments

Comments
 (0)