Re: Strong vs. Normal Thread Safety.



frege wrote:
....

The gist of Chris' post is that
- boost::shared_ptr doesn't do this.
- Chris has a smart_ptr that can do this.
That's his point.


Now, my question:

I also have a smart_ptr that can handle this situation, however...
when setting g_foo to the new global:

g_foo = some_other_ref_counted_ptr;

do you (Chris) have a version where some_other_ref_counted_ptr might
also be in the middle of an assignment? In my version,
some_other_ref_counted_ptr has to be 'stable' during the assign (the
refcount can change, but what it points to cannot change).

My use cases always had some_other_ref_counted_ptr being stable, so I
didn't persue it too far, but it would be nice to remove that
limitation.

AFAIK, yes. Everything is atomic. You will either see the new value
of the source ptr or the old value.

Should even handle
g_foo = g_foo;

while
g_bar = g_foo;

and while
g_foo = g_bar;

are happening all simutaneously. Note that the expressions aren't atomic.
Just the pointer loads and stores.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software. .



Relevant Pages