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.
2421 Discussions

enumerable_thread_specific and copy construction

hagai_sela
Beginner
123 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
123 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).
hagai_sela
Beginner
123 Views
I am using it as part of the intel c++ compiler suite, version 11.1, build 072.
ARCH_R_Intel
Employee
123 Views
It's a problem that was reported by another customer and fixed in TBB 3.0 update 1.
Vladimir_P_Intel2
123 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
Reply