Skip to content

Commit 1c250f7

Browse files
committed
Add a link to more efficient thread-safe singleton.
1 parent 2ed3294 commit 1c250f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

creational/singleton-pattern.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ So only the members of class can access the private constructor, and other objec
2222

2323
2. Create a static creation method that acts as a constrcutor
2424

25-
#### Simple Singleton
25+
### Simple Singleton
2626

2727
```c++
2828
class Singleton {
@@ -75,7 +75,7 @@ int main() {
7575
}
7676
```
7777
78-
#### Thread-safe Singleton
78+
### Thread-safe Singleton
7979
8080
```c++
8181
class Singleton {
@@ -111,6 +111,10 @@ Singleton* Singleton::getInstance(const std::string& value) {
111111
}
112112
```
113113

114+
### More Efficient Implementations
115+
116+
[fanweng/cpp-programming](https://github.com/fanweng/cpp-programming/blob/master/knowledge-base/concurrency/examples/singleton.cpp)
117+
114118
## Caveats
115119

116120
It is possible to *subclass* a singleton class by making the constructor **protected** instead of private.

0 commit comments

Comments
 (0)