Skip to content
Snippets Groups Projects
Commit 3a016e2c authored by Christian Engwer's avatar Christian Engwer
Browse files

[singleton] apply a simple fix for the multi-threading issue

for details see FS#1398
parent 45d37f63
No related branches found
No related tags found
No related merge requests found
......@@ -52,8 +52,6 @@ namespace Dune
template<class T>
class Singleton
{
/** @brief Smartpointer to the instance. */
static std::unique_ptr<T> instance_;
protected:
/* @brief Private constructor. */
Singleton(){}
......@@ -67,17 +65,16 @@ namespace Dune
* @brief Get the instance of the singleton.
* @return The instance of the singleton.
*/
static T& instance()
DUNE_EXPORT static T& instance()
{
/* Smartpointer to the instance. */
static std::unique_ptr<T> instance_;
if(instance_.get() == 0)
instance_ = std::unique_ptr<T>(new T());
return *instance_;
}
};
template<class T>
typename std::unique_ptr<T> Singleton<T>::instance_;
} // namespace Dune
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment