|
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.
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk