is it possible to initialize thread local storage automatically?

Hi! I'm looking for a method to execute some code for each thread starting. It suffices to run that code for each boost::thread. I want to initialize some thread local storage for each thread automatically. The creating(!) thread shall supply an initial value and the created(!) thread shall receive this value, essentially a copy of some thread local variable. That is the new thread shall create a copy of the same variable which the creating thread has. Is that possible using boost::thread? I hope my explaination is clear enough. Frank

Hi!
I'm looking for a method to execute some code for each thread starting. It suffices to run that code for each boost::thread. I want to initialize some thread local storage for each thread automatically. The creating(!) thread shall supply an initial value and the created(!) thread shall receive this value, essentially a copy of some thread local variable. That is the new thread shall create a copy of the same variable which the creating thread has. Is that possible using boost::thread?
I hope my explaination is clear enough.
Frank I think you could pass the value to your thread function as bare pointer and
Frank Birbacher wrote, On 14.6.2008 22:55: then store it in boost::thread_specific_ptr<>. -- VH

Hi! Václav Haisman schrieb:
I think you could pass the value to your thread function as bare pointer and then store it in boost::thread_specific_ptr<>.
Ok, I would then encapsulate this behaviour in my own thread class that wraps boost::thread. The thread_specific_ptr shall be initialized automatically, that is without additional code at the thread creation site. Frank
participants (2)
-
Frank Birbacher
-
Václav Haisman