[cpp-threads] Failed compare-and-swap
Lawrence Crowl
Lawrence at Crowl.org
Thu Aug 2 23:36:35 BST 2007
On 8/2/07, Peter Dimov <pdimov at mmltd.net> wrote:
> Lawrence Crowl wrote:
> > On 8/2/07, Boehm, Hans <hans.boehm at hp.com> wrote:
>
> >> Does it make sense to use an additional overload instead of a default
> >> value, so that failure_order can effectively default to
> >> success_order? I think that's clearly the correct default for
> >>
> >> seq_cst, relaxed, and release
> >>
> >> since release becomes vacuous in the failure case, since there is no
> >> store.
> >
> > That could work, but we'd need three overloads.
>
> Two are enough for that default.
>
> compare_swap( int& e, int d, memory_order w, memory_order r );
>
> compare_swap( int& e, int d, memory_order w = memory_order_seq_cst )
> {
> compare_swap( e, d, w, w );
> }
Ah, yes, if you switch the order of parameters. Hans has already
said he likes the switched order. Any other opinions?
> The first overload can be made to strip release from r.
I think that if the parameter is explicit, it should be exactly right.
We currently require programmers to use the right form, and I'd
like to leave it that way.
--
Lawrence Crowl
More information about the cpp-threads
mailing list