[cpp-threads] memory model
Peter Dimov
pdimov at mmltd.net
Fri Apr 29 13:47:59 BST 2005
Doug Lea wrote:
>> Yes. A qualifier approach is also error-prone. This can't be
>> designed out. - Checkable by compiler:
>>
>> More checkable than volatile.
>
> I was referring here to the fact that in the qualifier/volatile
> version, the qualifier declares that every load of a variable must
> have acquire semantics (etc.). So you can't forget to do it. No such
> checks seem possible in the function template approach.
Yes, you are right. Alexander's atomic<> template does have this property.
The function template formulation is razor-blades-extreme-edition.
On an unrelated note, I wonder what the semantics of x = y are supposed to
be under the new volatile when x and y are volatile variables of a struct
type that contains two or more pointers (this code is valid today, so it
can't be made a compile-time error.)
More information about the cpp-threads
mailing list