From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2005-04-04 15:03:15
Peter Dimov wrote:
> xadd is branchless; it just returns the old value, whereas inc doesn't. MSVC
> always generates lock xadd, even for _InterlockedIncrement, BTW.
Well, maybe. But you need value neither for increments nor decrements.
(I mean that for decrements you can simply rely on ZF flag). Oder?
> void release() // nothrow
> if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
> if( (long volatile&)weak_count_ == 1 ) // no weak ptrs
Nah. For the sake of killing C/C++ volatiles rather sooner than later,
I strongly suggest that you hide that load in asm. Just add load+cmp
followed by ZF branch prior to "lock dec" which also sets ZF, IIRC.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk