[cpp-threads] Failed compare-and-swap

Herb Sutter hsutter at microsoft.com
Wed Aug 1 05:37:29 BST 2007


Bill wrote:
> I cast my vote for saying that a failed compare and swap or failed
> trylock should have no synchronization semantics.
>
> The only idioms I know of that would depend on failed atomic
> operations having synchronization semantics are so problematical that
> we should do everything we can to discourage people from trying to
> use them.

Do you feel that "using a CAS as an atomic load" is a problematic idiom and should be not just discouraged but outlawed? (I'm actually open to that option, I'm just trying to state it as strongly as it probably should be stated, because if we don't require the synchronization semantics on failure then we really do outlaw it in portable code.)

> By giving fail operations semantics, you also rule out possible
> implementation strategies that might be advantageous in some current
> or future platform.




More information about the cpp-threads mailing list