Skip to content

Commit 9876524

Browse files
committed
fix tbb compat
1 parent 485c90d commit 9876524

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

include/io/multithreaded_block_module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ struct BlockCompressReaderMT {
314314
OrderedBlock block;
315315
while( true ) {
316316
if( sequencer_node.try_get(block) ) {
317-
decompressor_limiter_node.decrementer().try_put(tbb::flow::continue_msg{});
317+
qio::tbb_compat::decrementer(decompressor_limiter_node).try_put(tbb::flow::continue_msg{});
318318
available_blocks.push(current_block);
319319
current_block = block.block;
320320
current_blocksize = block.blocksize;

include/io/tbb_flow_compat.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,35 @@
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

1214
namespace qio {
1315
namespace 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
3136
template <class T>
3237
struct 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
4757
template <class T>
4858
struct 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

Comments
 (0)