diff options
author | Johannes Schickel | 2007-05-22 14:17:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-05-22 14:17:44 +0000 |
commit | 8ff17142c5f47dacaa6ae247b92e6d6b5a16d8ac (patch) | |
tree | bbf31da0b37041247662d2cba2d4c9fc00e3fce4 /common | |
parent | a178c25ea2b35d226350ab2aee23c61290281124 (diff) | |
download | scummvm-rg350-8ff17142c5f47dacaa6ae247b92e6d6b5a16d8ac.tar.gz scummvm-rg350-8ff17142c5f47dacaa6ae247b92e6d6b5a16d8ac.tar.bz2 scummvm-rg350-8ff17142c5f47dacaa6ae247b92e6d6b5a16d8ac.zip |
Simpilified Singleton implementation and usage.
svn-id: r26922
Diffstat (limited to 'common')
-rw-r--r-- | common/config-manager.cpp | 2 | ||||
-rw-r--r-- | common/singleton.h | 13 |
2 files changed, 3 insertions, 12 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp index f8426f18d0..41f3c1a7e9 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -33,8 +33,6 @@ #include "common/file.h" #include "common/util.h" -DECLARE_SINGLETON(Common::ConfigManager); - #ifdef __PLAYSTATION2__ #include "backends/platform/ps2/systemps2.h" #endif diff --git a/common/singleton.h b/common/singleton.h index 5e72e72230..f26324999e 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -37,8 +37,6 @@ private: Singleton<T>(const Singleton<T>&); Singleton<T>& operator= (const Singleton<T>&); - static T* _singleton; - /** * The default object factory used by the template class Singleton. * By specialising this template function, one can make a singleton use a @@ -58,16 +56,13 @@ public: public: static T& instance() { - // TODO: We aren't thread safe. For now we ignore it since the - // only thing using this singleton template is the config manager, - // and that is first instantiated long before any threads. + // TODO: We aren't thread safe. // TODO: We don't leak, but the destruction order is nevertheless // semi-random. If we use multiple singletons, the destruction // order might become an issue. There are various approaches // to solve that problem, but for now this is sufficient - if (!_singleton) - _singleton = T::makeInstance(); - return *_singleton; + static T *instance = T::makeInstance(); + return *instance; } protected: Singleton<T>() { } @@ -80,8 +75,6 @@ protected: typedef T SingletonBaseType; }; -#define DECLARE_SINGLETON(T) template<> T* Common::Singleton<T>::_singleton=0 - } // End of namespace Common #endif |