On Jan 30, 1:00 pm, Gerhard Fiedler <geli...@gmail.comwrote:
On 2008-01-30 08:50:26, James Kanze wrote:
what's important here isn't the semantics of volatile, but the fact that
T* volatile isn't the same type as T* volatile.)
Is this a typo?
I think so:-). What I probably meant to say was that T*& isn't
the same as T* volatile&. (Note that T* volatile and T* are the
same types, at least when they're return values.)
[...]
In sum, the implementation defined semantics of volatile
are, in most cases, totally useless for anything.
Does this mean that it is not necessary to declare variables
that are accessed (read and write) by different threads as
volatile? (In addition to the necessary locking, of course.)
It depends on what the threading specifications (and the
compiler definition of volatile) say. Under Posix, if you
haven't locked, volatile isn't sufficient, and if you have, it
isn't necessary. Current Windows works about the same, I think,
although I find it very hard to find any real published
specifications.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34