07-02-2010 02:24 AM
What happens to TLS combinable and enumerable_thread_specific objects between calls to parallel algorithms such as parallel_for? Are they destroyed? If the task_group object which initialized TLS objects is destroyed, does it destroy the TLS objects as well? What if the task_scheduler_init is destroyed or initialize method is called? What happens to TLS objects?
New Contributor III
07-02-2010 08:43 AM
These objects follows the same life-time rules as C++ objects of any other type with the following exception. You can think of them as a list (or vector), elements of which correspond to individual threads that accessed it. Thus when a thread gets destroyed, the element that corresponded to it is erased too. Therefore manipulations with task_scheduler_init may affect the contents of TBB TLS objects, but not their lifetime. Note also that I said "may affect". This is because terminating a particular task_scheduler_init instancenot not always destroys underlying threads.