We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2abb1fd commit 87488f1Copy full SHA for 87488f1
1 file changed
src/Singleton/Conceptual/ThreadSafe/main.cc
@@ -112,13 +112,10 @@ std::mutex Singleton::mutex_;
112
*/
113
Singleton *Singleton::GetInstance(const std::string& value)
114
{
115
+ std::lock_guard<std::mutex> lock(mutex_);
116
if (pinstance_ == nullptr)
117
- std::lock_guard<std::mutex> lock(mutex_);
118
- if (pinstance_ == nullptr)
119
- {
120
- pinstance_ = new Singleton(value);
121
- }
+ pinstance_ = new Singleton(value);
122
}
123
return pinstance_;
124
0 commit comments