[cpp-threads] atomic operations package

Boehm, Hans hans.boehm at hp.com
Wed Aug 24 21:33:10 BST 2005


I've been tempted to drop the sync parameters, too.  Especially
since it would be consistent with the C atomic_ops library I've been
working on.

But I think the parameterization does have its advantages:

It seems to me that for the atomic read-modify-write primitives,
you usually want all N (4?) variants.  And it's not that
uncommon that you want to define your own, presumably based on a
CAS loop.

Without parameterization, I need N separate definitions (possibly
added on demand).  With parameterization, I think I just need
one, which is really no more complicated.

There are probably other examples of this.  But this one is simple
enough to convince me that it should probably be supported.

It still seems to me that if we use templates only at the top level,
with some predefined instantiations for "template haters" and C
programmers, and "run-time" parameterization for the sync arguments,
we should be OK.  And since these functions should normally be
inlined, there shouldn't be any run-time overhead.  (Unlike
the template version, we can't guarantee that, but that's minor.)
And we avoid the name space issues associated with macros.

If there's no interest on the C side, I'd vote for dropping or
minimizing the predefined instantiations.  If there is interest,
I think they're essential, since that's all you'd get in C.

If this sounds plausible, I can change the proposal on the web
page to reflect this.

Hans

> -----Original Message-----
> From: 
> Cpp-threads_decadentplace.org.uk-bounces at decadentplace.org.uk 
> [mailto:Cpp-threads_decadentplace.org.uk-bounces at decadentplace
> .org.uk] On Behalf Of Doug Lea
> Sent: Wednesday, August 24, 2005 5:31 AM
> To: cpp-threads at decadentplace.org.uk
> Subject: Re: [cpp-threads] atomic operations package
> 
> 
> Alexander Terekhov wrote:
> > On 8/23/05, Peter Dimov <pdimov at mmltd.net> wrote:
> > [...]
> > 
> >>The C people would never accept the <> syntax. They hate templates 
> >>with a passion. :-)
> > 
> > 
> > Why not simply give a bunch of macros to templates haters?
> > 
> 
> Why not just kill the sync arguments all together and 
> hardwire all of the possibilities into different functions? 
> When Hans eventually (and inevitably :-) convices you that we 
> can only support relatively small number (max 4?) of them per 
> load/store/CAS, there won't be enough of them to warrant 
> macro/template treatment anyway.
> 
> -Doug
> 
> -- 
> cpp-threads mailing list
> cpp-threads at decadentplace.org.uk 
> http://decadentplace.org.uk/mailman/listinfo/cpp-threads_decad
entplace.org.uk




More information about the cpp-threads mailing list