This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Tweaking atomics and memory barriers in shared_ptr
- From: "Jonathan Wakely" <jwakely dot gcc at gmail dot com>
- To: "Paolo Carlini" <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 6 Nov 2007 14:35:37 +0000
- Subject: Re: Tweaking atomics and memory barriers in shared_ptr
- References: <4348dea50710270529q461462d8p553339a37fbd9191@mail.gmail.com> <472D9A12.40305@suse.de>
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