From 1727a98f603dcb55a114667c30d8e93db66cd47a Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 15 Apr 2019 11:07:19 +0200 Subject: [PATCH] improved performance of Singleton --- src/core/singleton/Singleton.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/singleton/Singleton.h b/src/core/singleton/Singleton.h index 36a7ea5f8..ead687d0c 100644 --- a/src/core/singleton/Singleton.h +++ b/src/core/singleton/Singleton.h @@ -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; -- GitLab