|
Boost : |
From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-08-07 10:51:03
----- Original Message -----
From: "Jason Stewart" <jstewart_at_[hidden]>
> This might do what you want because it avoids locking the mutex after the
> object has been safely initialized. Apologies to Mr. Becker if I
> misrepresented this. Also, I have not really looked at the boost threads
so
> I don't know if I implemented the locking correctly.
This is known as the DCL pattern, and it invokes undefined behavior (by
POSIX memory visibility rules, which are the only rules likely to be usable
here). The end result is that there are many platforms on which this will
fail. For a lengthy discussion of the issues check out this article:
http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html.
Bill Kempf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk