[cpp-threads] Increment/decrement operators on atomics package

Raul Silvera rauls at ca.ibm.com
Fri Apr 20 11:21:32 BST 2007


Lawrence, something that we briefly touched on in Oxford was the question 
of increment operators in the atomics package doing a RMW operation.

I think that it is in generally confusing for t+=1 and t=t+1 to have 
different semantics for an Atomic t. The difference would be that t+=1 
would be RMW operation while t=t+1 is a sequence of 
load_acquire;add;store_release.
The main concern is that users consider these two idioms interchangeable 
and replace one by the other only based on programming style.

My proposal for this issue is to make t+=1 have the same semantics as 
t=t+1 (no RMW). Instead, a separate member functions would be provided to 
do RMW operations (e.g t.atomic_inc(1)).
An alternative proposal would be not to define increment operators for the 
atomic class.

Do you consider this a valid concern? Thanks...

--
Raúl E. Silvera         IBM Toronto Lab         Team Lead, Toronto 
Portable Optimizer (TPO)
Tel: 905-413-4188       T/L: 969-4188           Fax: 905-413-4854 
D2/KC9/8200/MKM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.decadentplace.org.uk/pipermail/cpp-threads/attachments/20070420/4fe8d785/attachment.html


More information about the cpp-threads mailing list