I'm reading boost::shared_ptr
source code and found it using this function to increase shared_ptr's use count(reference count):
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
);
}
Why not simply use the operator++
to do this? Does this give better performance?