Re: [RFC] Atomic Reference Counting - Do you think this would be useful to Boost?
"Chris Thomasson" <cristom@comcast.net> writes:
shared_ptr _is_ thread safe as documented, and it _does_ use true
atomic reference counting on supported platforms.
I think I have to disagree here, unless, they are now using logic like Joe
Seighs atomic_ptr? Or, something this:
http://groups.google.com/group/comp.programming.threads/browse_frm/thread/f2
c94118046142e8
(hummm, Joes atomic_ptr shows up in a SUN patent... Interesting! :)
Neither of your quotings make it particularly clear what atomic_ptr does
over shared_ptr; I'm sure there is something, but I suspect not that
shared_ptr generally isn't thread safe. What is it?
AFAICT, shared_ptr uses nothing like that. I think you may be confusing
normal reference counting, with atomically thread-safe reference counting;
there is a BIG difference between the two...
From shared_ptr's source for the x86 platform on gcc:
inline void atomic_increment( int * pw )
{
//atomic_exchange_and_add( pw, 1 );
__asm__
(
"lock\n\t"
"incl %0":
"=m"( *pw ): // output (%0)
"m"( *pw ): // input (%1)
"cc" // clobbers
);
}
That looks fairly atomic to me. I appreciate that this doesn't mean
that every use of shared_ptr is thread safe. However, a good chunk of
them are, if the documentation is correct.
Do you think the documentation is wrong? In what way is it wrong?
--
Gru????, Jens
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]