44#include < utility>
55#if __has_include(<tbb/version.h>)
66#include < tbb/version.h>
7- #elif __has_include(<oneapi/tbb/version.h>)
8- #include < oneapi/tbb/version.h>
7+ #elif __has_include(<tbb/tbb_stddef.h>)
8+ #include < tbb/tbb_stddef.h>
9+ #else
10+ #error "Unable to find a TBB version header"
911#endif
1012#include < tbb/flow_graph.h>
1113
1214namespace qio {
1315namespace tbb_compat {
1416
15- // Normalize old TBB flow-graph source APIs across versions.
17+ // Normalize the flow-graph API split between classic TBB (interface 11)
18+ // and oneTBB (interface 12+).
1619//
17- // Old interface :
20+ // Classic TBB :
1821// tbb::flow::source_node<T>
22+ // limiter_node.decrement
1923// body signature: bool(T & out)
2024//
21- // Newer interface :
25+ // oneTBB :
2226// tbb::flow::input_node<T>
27+ // limiter_node.decrementer()
2328// body signature: T(tbb::flow_control & fc)
2429//
2530// Normalized contract used below:
2631// bool(T & out)
2732//
2833// Return true and fill `out` to emit one message.
2934// Return false to stop the node.
30- #if defined(TBB_INTERFACE_VERSION ) && TBB_INTERFACE_VERSION >= 11102
35+ #if defined(TBB_INTERFACE_VERSION_MAJOR ) && TBB_INTERFACE_VERSION_MAJOR >= 12
3136template <class T >
3237struct source_node : tbb::flow::input_node<T> {
3338 using base_type = tbb::flow::input_node<T>;
@@ -43,6 +48,11 @@ struct source_node : tbb::flow::input_node<T> {
4348 return out;
4449 }) {}
4550};
51+
52+ template <class LimiterNode >
53+ inline auto & decrementer (LimiterNode & node) {
54+ return node.decrementer ();
55+ }
4656#else
4757template <class T >
4858struct source_node : tbb::flow::source_node<T> {
@@ -52,6 +62,11 @@ struct source_node : tbb::flow::source_node<T> {
5262 source_node (tbb::flow::graph & graph, Body && body) :
5363 base_type (graph, std::forward<Body>(body), false ) {}
5464};
65+
66+ template <class LimiterNode >
67+ inline auto & decrementer (LimiterNode & node) {
68+ return node.decrement ;
69+ }
5570#endif
5671
5772} // namespace tbb_compat
0 commit comments