[cpp-threads] High-level vs. low-level

Herb Sutter hsutter at microsoft.com
Fri Jul 14 14:38:47 BST 2006


Alexander wrote:
> On 7/14/06, Boehm, Hans <hans.boehm at hp.com> wrote:
> > > -----Original Message-----
> > > From: Alexander Terekhov
> > > > [Peter:]
> > > > This is a very good question. I'm still undecided on whether:
> > > >
> > > >     atomic_load_acq( &x );
> > > >
> > > > should work on x being a plain int.
> > >
> > > Should not.

I agree.

> > I think there is a strong argument to the contrary: Existing
practice.
> > That's why the current proposal takes the opposite route, in spite
of
> > the fact that Lawrence once convinced me of Alexander's opinion.
> >
> > I think nearly every compiler currently provides intrinsics that
perform
> > atomic read-modify-write operations on ordinary integers.  I have
yet to
> > find one that provides a corresponding atomic read (or simple store)
> > operation, so I think these are all somewhat broken.  (And you can't
> > reasonably provide those operations without seriously addressing
> > ordering issues, which they generally don't.)  But certainly by 2009
> > there will be a fair amount of code that uses them,
> 
> First this is just speculation. Second, existing practice prior C++
> standardization for "new", for example, was to return zero (and not
> throw). The standard broke a lot of existing practice code.

I have to agree again.

FWIW, in some cases, existing practice can be a strong argument to
support the feature (since it's popular) but in a different way (because
existing practice is incompatible), even when using the syntax of some
existing practice might be desirable in itself for reasons other than
compatibility. For example, hash_set and hash_map are the obvious names
that everyone wanted, but because existing implementations already used
exactly those names with different meanings, we had to standardize
unordered_set and unordered_map.

In this case there's a compelling reason to do a better job than
existing practice, and we're not going to be source-compatible with all
the syntaxes out there right now anyway.

Herb




More information about the cpp-threads mailing list