Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Concurrent Queue from Herb Sutter article

laurentb
Beginner
129 Views
Hi,
Today was planing to implement Herbe Sutter article
http://www.ddj.com/hpc-high-performance-computing/212201163
using tbb::atomic, but tbb::atomic doesn't seems to support incomplete type.

How can I handle this issue ?

For example this kind of code doesn't compile
because Node is incomplete inside Node.

[cpp]#include "tbb/atomic.h"

struct Node
{
tbb::atomic ptr;
} Node;

int main(int argc, char *argv [])
{
Node nd;
return 0;
}[/cpp]


How do I fix this pb ? Do I have to split Node implementation from Node usage, like atomic itself.


0 Kudos
4 Replies
Alexey_K_Intel3
Employee
129 Views
Just update toa more recent release of TBB. The problem has been addressed in TBB 2.1 Update 2.
laurentb
Beginner
129 Views
Thanks you very much
Updating to the last version fix the pb
Charles_Tucker
Beginner
129 Views
Just update toa more recent release of TBB. The problem has been addressed in TBB 2.1 Update 2.

Having not looked too closely at the most up-to-date code, how was this problem addressed? I'm curious how pointer-types are configured for increment/decrement operations without evaluating the size of the incomplete type.
RafSchietekat
Black Belt
129 Views
"Having not looked too closely at the most up-to-date code, how was this problem addressed? I'm curious how pointer-types are configured for increment/decrement operations without evaluating the size of the incomplete type."
Template class member functions are instantiated just in time, and only then must all details be known. Previously, sizeof(T) was evaluated before inheriting common behaviour. I myself tried to solve the problem by not inheriting the operations, using macros instead to inject the operations at both the atomic hierarchy exit(s) and in the abstract subclass for further specialisation (where the increment value would always be 1). Apparently, tbb21_20090313oss instead inherits from a template based on T for atomic and char otherwise, thus avoiding to need to know sizeof(T) already, and inheritance does not force instantiation yet, so this also works. Nicely done!

(Added) Actually, I used #include for the injections, because the included file itself uses macros. Shiver!
Reply