|
Boost : |
From: Andrey Semashev (andysem_at_[hidden])
Date: 2008-03-04 12:59:14
Peter Dimov wrote:
>>> Yes, and I see nothing bad with it. Shared_ptr does precisely the same,
>>> and since this cleanup function is intended to do the same as
>>> shared_ptr's deleter does, I don't see why would the interface have to
>>> differ.
>
> thread_specific_ptr was more or less intended to provide a C++ equivalent to
> pthread_setspecific, and the POSIX interface associates a single destructor
> function to a TSD slot. It's technically possible to emulate shared_ptr, but
> is there a reason for that?
There is no specific reason for that. That feature would just follow
from the interface if thread_specific_ptr was consistent with shared_ptr.
As for the consistency itself, well, in my opinion this feature can
potentially be useful if one would want to allocate memory for TSD in a
thread-specific allocator or storage. This may be useful for both
performance optimization and memory consumption monitoring and control
on per-thread basis. Besides, overall interface consistency is a sign of
a good library design.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk