C/C++
dclock1.txt
Associated article: C++ and The Perils of Double-Checked Locking: Part I
Tags: Tools C/C++
Published source code accompanying Part 1 of the article by Scott Meyers and Andrei Alexandrescu in which they examine the C++ and the Double-Checked Locking pattern.
C++ and the Perils of Double-Checked Locking: Part 1
by Scott Meyers and Andrei Alexandrescu
Example 1:
1 // from the header file
2 class Singleton {
3 public:
4 static Singleton* instance();
5 ...
6 private:
7 static Singleton* pInstance;
8 };
9
10 // from the implementation file
11 Singleton* Singleton::pInstance = 0;
12
13 Singleton* Singleton::instance() {
14 if (...


