Community
cancel
Showing results for 
Search instead for 
Did you mean: 
laurentb
Beginner
49 Views

Concurrent Queue from Herb Sutter article

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
49 Views

Just update toa more recent release of TBB. The problem has been addressed in TBB 2.1 Update 2.
laurentb
Beginner
49 Views

Thanks you very much
Updating to the last version fix the pb
Charles_Tucker
Beginner
49 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
49 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