Re: [Patch/RFC] tr1::shared_ptr<> removal of lock, choosing thread safety
Paolo Carlini <pcarlini <at> suse.de>
2006-07-06 14:56:45 GMT
Hi Phillip,
>As a possible solution to the issue of the availability of atomic
>operations, I've been discussing the use of an additional boolean
>template parameter specifying whether thread safety is needed. This
>defaults to false, so existing single-threaded code should compile and
>run as usual.
>
>
In principle, we could maybe do that for tr1, but I don't think that
adding template parameters is the way to go, because a conforming
implementation of a standard facility is not allowed to do that and,
note, tr1::shared_ptr is already in the draft of C++0x... I would
suggest hiding it in a base class, or something similar (like we are
doing for the extension allocators). That is not going to be feasible
for anything already implemented, part of the current standard, because
of ABI-issues, of course.
About the more general issue of making good use of all the atomic
builtins, when available, I don't think we have in place a fully general
solution. Probably, apart from the "always safe" platforms (i.e.,
powerpc, alpha, ia64, s390), missing compiler support to easily detect
when the facility is actually available at compile time we have to leave
the choice to the user who knows what is doing...
Paolo.