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.
This commit is contained in:
Mathias Agopian 2010-05-28 15:13:30 -07:00
parent 26acf3fa06
commit b8510b98b5
1 changed files with 5 additions and 3 deletions

View File

@ -54,11 +54,13 @@ private:
* (eg: <TYPE>.cpp) to create the static instance of Singleton<>'s attributes,
* and avoid to have a copy of them in each compilation units Singleton<TYPE>
* 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);