From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-03-04 07:53:53
Andrey Semashev <andysem <at> mail.ru> writes:
> Anthony Williams wrote:
> > How is this to be managed? Cleanup handlers for the TLS key need to run in
> > the
> > context of each thread, and only run when a thread changes its value with
> > reset(), or when the thread exits. You cannot invoke a cleanup handler for
> > another thread.
> Hmm, I missed that. But how does it work now? I mean, how the cleanup
> handlers are called in the current implementation when the
> thread_specific_ptr is destroyed? You should call them in context of
> their threads anyway.
The cleanup handler is called in the context of each thread when the thread
exits --- the cleanup handler itself is reference counted. If you destroy a
thread_specific_ptr, and then access it from any thread (whether to get or set
the value), then the behaviour is undefined, as for any object accessed after
> > The thread_specific_ptr is a bit clunky altogether. I intend to come up with
> > something better in the future, but it may be moot once compilers start
> > implementing the new thread_local storage duration.
> I think, efforts on thread_specific_ptr are not completely worthless.
> Even after C++0x is out and supported by the most wide-spread compilers
> we will still have to write backwards-compatible code to support older
> compilers for some time. MSVC 6 support is an example of such evolution
-- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk