[cpp-threads] Yet another visibility question

Doug Lea dl at cs.oswego.edu
Wed Dec 20 01:44:21 GMT 2006


Peter Dimov wrote:
> Boehm, Hans wrote:
> 
>> We can argue about whether this should be considered a real
>> dependency. But as I argued earlier with Peter, if we assume it
>> isn't, I think dependency-based ordering becomes largely useless to
>> the programmer, since I can't reason about it without looking through
>> abstraction boundaries.
> 
> I don't agree. Provable dependencies are not uncommon and in this case I 
> can use a raw/release atomic. Unprovable dependencies will need an 
> acquire. I can live with that.
> 

Maybe I'm not following this discussion closely enough, but it
would seem that if you want to impose an ordering, then you
should always state it, and then let the compiler worry about
whether that actually requires a fence on the platform you run on?

In other words, the following would almost never be correct:
   r1 = x.load_raw(); // should be load_acquire
   r2 = *r1;
And maybe tools could help find such errors.

Or am I missing the point?

The alternative of defining dependencies seems to me to
be a losing battle, at least in C++.

-Doug






More information about the cpp-threads mailing list