Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2463 Discussions

enumerable_thread_specific and copy construction

hagai_sela
Beginner
278 Views
Hi,
I am using enumerable_thread_specific for thread local storage, and I want each copy to be default-constructed.
My problem is that for each item which is created, the copy constructor is called instead of the default constructor. I looked at the code and it seems that's what tbb does...

http://www.threadingbuildingblocks.org/files/documentation/a00292.html

in line 638:
local_index = my_locals.push_back(*my_exemplar_ptr) - my_locals.begin();

when calling push_back with the previously constructed my_exemplar_ptr the copy constructor will be called instead of the default constructor.

I guess I can use a factory method to create the objects, but the manual clearly says that if I call the default enumerable_thread_specific constructor than each copy created will be default constructed. Well, it's not...

Thanks,
Hagai.
0 Kudos
4 Replies
RafSchietekat
Black Belt
278 Views
What version is that? tbb30_056oss (latest commercially aligned) does seem to implement this exactly as per the specification (even if it accidentally calls that "zero initialization" on enumerable_thread_specific.h:587).
0 Kudos
hagai_sela
Beginner
278 Views
I am using it as part of the intel c++ compiler suite, version 11.1, build 072.
0 Kudos
ARCH_R_Intel
Employee
278 Views
It's a problem that was reported by another customer and fixed in TBB 3.0 update 1.
0 Kudos
Vladimir_P_1234567890
278 Views
AFAIR, this version contains TBB 2.2 U3, you need to get newer version, TBB 3.0 U1 as Arch pointed or newer.
thanks
--Vladimir
0 Kudos
Reply