This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tweaking atomics and memory barriers in shared_ptr


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]