Skip to content
Snippets Groups Projects
Commit 1727a98f authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

improved performance of Singleton

parent 75d75fe8
No related merge requests found
......@@ -86,7 +86,8 @@ public:
//@{
static const shared_ptr<T>& instance()
{
std::lock_guard<std::mutex> lock( instanceMutex_ );
// this implementation is thread safe
// https://stackoverflow.com/questions/1661529/is-meyers-implementation-of-the-singleton-pattern-thread-safe
static shared_ptr<T> object( new T() );
isInstantiated_ = true;
return object;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment