On Tue, 21 Sep 2004 18:40:03 +0100, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Daniel Jin <Da*******@discussions.microsoft.com> wrote: but if you are running the code on a x86 machine, double locking should be
ok, correct? though it could potentially be ported to a system with very
weak memory model.
I don't know whether it's definitely correct, even on x86. It may well
be, but I certainly wouldn't like to write a load of code assuming it.
You never know where your code will end up...
CLI I 12.6.8 says:
"It is explicitly not a requirement that a conforming implementation
of the CLI guarantee that all state updates performed within a
constructor be uniformly visible before the constructor completes.
CIL generators may ensure this requirement themselves by inserting
appropriate calls to the memory barrier or volatile write
instructions. "
When I read this it tends to make me want to err on the safe side and
avoid the situation altogether. You never know what conforming
implementation your code might end up on...
--
Scott
http://www.OdeToCode.com