From b8510b98b5eb92333157db1359df6f2bbbfb2b39 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 28 May 2010 15:13:30 -0700 Subject: [PATCH] Fix a typo in Singleton<> it could cause the sLock field to be emitted several times in different compilation unit. it also prevented to have 2 Singleton<> in the same file. --- include/utils/Singleton.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/utils/Singleton.h b/include/utils/Singleton.h index bc7626a82..3b975b4c4 100644 --- a/include/utils/Singleton.h +++ b/include/utils/Singleton.h @@ -54,11 +54,13 @@ private: * (eg: .cpp) to create the static instance of Singleton<>'s attributes, * and avoid to have a copy of them in each compilation units Singleton * is used. + * NOTE: we use a version of Mutex ctor that takes a parameter, because + * for some unknown reason using the default ctor doesn't emit the variable! */ -#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ - template class Singleton< TYPE >; \ - template< class TYPE > Mutex Singleton< TYPE >::sLock; \ +#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ + template class Singleton< TYPE >; \ + template<> Mutex Singleton< TYPE >::sLock(Mutex::PRIVATE); \ template<> TYPE* Singleton< TYPE >::sInstance(0);