0

How do I determine thread id in a TBB parallel loop body?

Essentially what I need is per-thread copies of an object so I thought I'd have those in array indexed by thread id.

I'm looking for the portable TBB way of doing this, not OS native services.

lsr
  • 23
  • 3

1 Answers1

1

The search term you are looking for is "thread-local storage". Since you are already using TBB, you should probably just use the facilities it provides:

https://www.threadingbuildingblocks.org/docs/help/reference/thread_local_storage.htm

Nemo
  • 65,634
  • 9
  • 110
  • 142
  • great, thanks! enumerable_thread_specific is what I wanted btw tbb::this_tbb_thread::get_id() is what I'd have used if that TLS container wasn't available – lsr Feb 06 '16 at 01:20