
25 Feb
2009
25 Feb
'09
10 p.m.
k-oli@gmx.de writes:
can I create an static thread specific pointer for class which will initalized by different threads?
struct X { static thread_specific_ptr< U > tss_ptr_; };
in some threads:
X::tss_ptr_.reset( new U);
And for each thread X::tss_ptr_ will point to a different object in the freestore?
Yes. That's exactly the intended usage. Only the thread that calls reset() can access the object passed in. Anthony -- Author of C++ Concurrency in Action | http://www.manning.com/williams just::thread C++0x thread library | http://www.stdthread.co.uk Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976