Boost logo

Boost :

Subject: Re: [boost] [thread] static thread_specific_ptr?
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-02-25 17:00:29

k-oli_at_[hidden] 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.


Author of C++ Concurrency in Action |
just::thread C++0x thread library   |
Just Software Solutions Ltd         |
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at, gregod at, cpdaniel at, john at