From: Talbot, George (Gtalbot_at_[hidden])
Date: 2006-11-16 11:44:52
Thanks for looking at that. I was also thinking--does
enable_shared_from_this need to have an "enable_atomic_from_this"
That would also imply an atomic_weak type.
-- George T. Talbot <gtalbot_at_[hidden]> > -----Original Message----- > From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] > On Behalf Of Peter Dimov > Sent: Wednesday, November 15, 2006 11:42 AM > To: boost_at_[hidden] > Subject: Re: [boost] I think using spinlocks to simulate an > atomicshared_ptr... > > Sorry for the brief response, no time... > > Talbot, George wrote: > > > 2) Without any sort of 2-pointer-wide atomic assignment in hardware, > > operator= really looks like this: > > > > lock the source pointer > > make a local copy of it > > release the source pointer > > > > lock the destination > > set the value of the destination from the copy > > unlock the destination > > > > This won't deadlock, but has to make an extra copy of the pointer > > locally. > > There's no extra copy. shared_ptr::operator= does: > > shared_ptr( r ).swap( *this ); > > and the above does: > > lock source > shared_ptr tmp( src ); > unlock > > lock dest > dest.swap( tmp ); > unlock > > so the two are equivalent (modulo spinlock order). > > _______________________________________________ > Unsubscribe & other changes: > http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk