Tweaking atomics and memory barriers in shared_ptr
Jonathan Wakely
jwakely.gcc@gmail.com
Tue Nov 6 14:35:00 GMT 2007
On 04/11/2007, Paolo Carlini <pcarlini@suse.de> wrote:
> > 2) When lock-policy is _S_single the atomic *_dispatch functions in
> > ext/atomicity.h are used. For single-threaded code this doesn't
> > matter, but if __shared_ptr<T, _S_single> is used by multithreaded
> > programs then the lock-policy is not honoured, since fully-fenced
> > atomic ops will be used.
> >
> I'm much less enthusiastic about this part. Indeed, I noticed the issue
> some time ago, when I cleaned-up this stuff, but didn't consider the
> _S_single case to be worth the additional specializations. All in all,
> I'm in favor of committing immediately the hunks above (+ the volatile
> bit), then we'll see...
Hi Paolo,
thanks for the review. I've committed the patch without the new
_S_single specialisations. They could always be added later if there
is any demand for a non-threadsafe shared_ptr, and if there isn't
demand then you're right not to change the code.
With the new memory barrier usage and the comments I added, are you
happy if I close http://gcc.gnu.org/PR24347 ?
Now that this patch is done I'll prepare the patch for aliasing and
allocator support.
thanks,
Jon
More information about the Libstdc++
mailing list