$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [atomic] (op)_and_test naming
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-01-24 11:35:38
Hi,
I would like to ask for the community opinion on the naming of the 
(op)_and_test functions that appeared in Boost.Atomic 1.66.
As you probably know, 1.66 included a few new atomic operations, some of 
which have the name (op)_and_test (e.g. add_and_test, sub_and_test, 
etc.) These operations perform the (op) on the atomic value and test if 
the result is zero, so that instead of this:
     if (a.fetch_sub(1) - 1 == 0)
one could write this:
     if (a.sub_and_test(1))
Also, the generated code for these operations can potentially be more 
efficient.
Recently I received this request:
https://github.com/boostorg/atomic/issues/11
which basically asks to change the result of the functions to the 
opposite. I can see that the current naming could be confusing, 
especially given that other operations like bit_test_and_set return the 
previous bit value (i.e. true if the bit was 1). That would be a 
breaking change, but the new operations were announced as experimental 
in the release notes, so if there is consensus that the result should 
indeed be changed, I'm ready to comply.
Another solution is change (op)_and_test naming to something else that 
is more clear. In that case I could deprecate the (op)_and_test variants 
and provide the functionality under the new names. I would welcome 
suggestions for a better naming scheme, if you feel this is the right 
way. My only ask is that the new names be concise, if possible.
Lastly, if you think the current naming is fine or there is another way 
to resolve the confusion, please comment as well. I would appreciate 
your opinion in any case.
Thanks.