Skip to content
Snippets Groups Projects
Commit 6b3ad219 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

Merge branch 'feature/46-make-singleton-thread-safe' into 'master'

[Singleton] Make creation of the instance thread-safe.

Closes: #46.

See merge request !141
parents 6878507d fad06840
No related branches found
No related tags found
1 merge request!141[Singleton] Make creation of the instance thread-safe.
Pipeline #
......@@ -3,8 +3,6 @@
#ifndef DUNE_SINGLETON_HH
#define DUNE_SINGLETON_HH
#include <memory>
#include <dune/common/visibility.hh>
/**
......@@ -69,11 +67,8 @@ namespace Dune
*/
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_;
static T instance_;
return instance_;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment