Merge "Fix multiton issue" am: 78b285b367
am: 6d7751a13b
am: dafd687617
Change-Id: I7e7369361dda3df0e97169c0d06ce24c57490c7d
This commit is contained in:
commit
477b3fc355
1 changed files with 13 additions and 5 deletions
|
@ -26,6 +26,16 @@
|
|||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Singleton<TYPE> may be used in multiple libraries, only one of which should
|
||||
// define the static member variables using ANDROID_SINGLETON_STATIC_INSTANCE.
|
||||
// Turn off -Wundefined-var-template so other users don't get:
|
||||
// instantiation of variable 'android::Singleton<TYPE>::sLock' required here,
|
||||
// but no definition is available
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wundefined-var-template"
|
||||
#endif
|
||||
|
||||
template <typename TYPE>
|
||||
class ANDROID_API Singleton
|
||||
{
|
||||
|
@ -56,11 +66,9 @@ private:
|
|||
static TYPE* sInstance;
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
Mutex Singleton<TYPE>::sLock;
|
||||
|
||||
template <typename TYPE>
|
||||
TYPE* Singleton<TYPE>::sInstance;
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file
|
||||
|
|
Loading…
Reference in a new issue