[cpp-threads] atomic operations package

Boehm, Hans hans.boehm at hp.com
Tue Aug 23 19:42:03 BST 2005


Do you have good connections on the C committee?  Could you get
some feedback as to whether they might be willing to adopt something
like this?

I'm more than happy to try to keep this somewhat C-compatible if
that will actually improve its chances of getting adopted by the C
committee.

In my view, the atomic<> template actually buys us something,
in that it can be applied to enumeration types, etc.  If we are striving
for C compatibility, doesn't it still make more sense to keep it,
and to add a bunch of definitions like:

typedef atomic<long> atomic_long;

?

In that way, C (and C++ users who hate templates) can use atomic_long
and friends, while ignoring the underlying templates?

If we go this route, we would probably have to drop the "object
oriented"
syntax for things like cas, and define them as standalone functions
as you do below, with the atomic as an explicit parameter.
I personally don't care much either way, but I'm afraid others will
object.  Does anyone else on this list care?

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 Peter Dimov
> Sent: Tuesday, August 23, 2005 10:42 AM
> To: cpp-threads at decadentplace.org.uk
> Subject: Re: [cpp-threads] atomic operations package
> 
> 
> Alexander Terekhov wrote:
> > On 8/23/05, Boehm, Hans <hans.boehm at hp.com> wrote:
> 
> >> 1) You make the ordering constraint a run-time parameter, 
> and I make 
> >> it a member template parameter.  My guess is that you almost never 
> >> want it to be a runtime parameter.
> >
> > It's not really meant to be a run-time parameter. It just 
> takes a bit 
> > less characters and is more readable IMO.
> 
> I prefer the "runtime" formulation and not using an atomic<> template 
> because this keeps the syntax C-compatible. The atomics 
> should - in my 
> opinion - be implemented as compiler intrinsics; these are 
> usually shared 
> between the C and C++ compiler.
> 
> The C people would never accept the <> syntax. They hate 
> templates with a 
> passion. :-)
> 
> atomic_load( &v, msync_acq )
> 
> is C-friendly. (That's also why v is passed by pointer and not by 
> reference.) 
> 
> 
> -- 
> 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