Boost logo

Boost :

From: Talbot, George (Gtalbot_at_[hidden])
Date: 2006-11-27 09:41:26

> Chris Thomasson wrote:
> Sent: Wednesday, November 22, 2006 11:32 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Preliminary working prototypeofatomic_shared--
> multithreaded wrapper for shared_ptr.
> "Talbot, George" <Gtalbot_at_[hidden]> wrote in message
> > Hi,
> > I've attached to this e-mail a working prototype of a wrapper for
> > shared_ptr that uses a spinlock so that the shared_ptr may be
> > atomically from multiple threads. For example, two threads can both
> > attempt to set the value of the same shared_ptr, and the last one
> > win. This wrapper includes a "compare_and_set" method for
> > lock-free-style "read, copy, attempt swap, repeat" updating to a
> > structure, though, of course because the wrapper uses a spinlock, it
> > isn't truly lock free.
> I suggest you take a look at a mostly lock-free implementation:
> Your wrapper uses the spinlock when it doesn't have to... A swap and a
cas > to shared locations that contain pointers to the refcount
> object do not need to be locked...

I know. I was just doing a simple prototype first that has the
interface that I want. I figure if I get everything working with the
simple stupid spinlock, then I can go back and re-work with atomic

> Weak reference count modifications do not need to be
> locked...

That's good to know.

> You don't need to use DWCAS either...

Don't I need to do that for assignment and compare_and_set for the
actual shared_ptr<>, since it's two words? (pointer to object and
pointer to refcount.)

This is good feedback. Thank you for the help.

George T. Talbot

Boost list run by bdawes at, gregod at, cpdaniel at, john at