Squashed commit of the following:

commit e5c24638f98162c3b75b4c67a16b510d38e31341
Author: Mathias Agopian <mathias@google.com>
Date:   Fri Apr 17 14:09:03 2009 -0700

    oops forgot this file.

commit 282642632d0cb12882eecf42e0fdfb2343275de1
Author: Mathias Agopian <mathias@google.com>
Date:   Fri Apr 17 14:07:32 2009 -0700

    use a helper macro for creating Singleton<>'s static attributes instances.
This commit is contained in:
Mathias Agopian
2009-04-17 14:15:18 -07:00
parent f670127afc
commit 2b1927f686
4 changed files with 15 additions and 6 deletions

View File

@@ -49,6 +49,18 @@ private:
static TYPE* sInstance;
};
/*
* use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file
* (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.
*/
#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \
template< class TYPE > Mutex Singleton< TYPE >::sLock; \
template<> TYPE* Singleton< TYPE >::sInstance(0);
// ---------------------------------------------------------------------------
}; // namespace android

View File

@@ -34,8 +34,7 @@
namespace android {
// ---------------------------------------------------------------------------
template<class BufferAllocator> Mutex Singleton<BufferAllocator>::sLock;
template<> BufferAllocator* Singleton<BufferAllocator>::sInstance(0);
ANDROID_SINGLETON_STATIC_INSTANCE( BufferAllocator )
Mutex BufferAllocator::sLock;
KeyedVector<buffer_handle_t, BufferAllocator::alloc_rec_t> BufferAllocator::sAllocList;

View File

@@ -44,8 +44,7 @@
namespace android {
// ---------------------------------------------------------------------------
template<class BufferMapper> Mutex Singleton<BufferMapper>::sLock;
template<> BufferMapper* Singleton<BufferMapper>::sInstance(0);
ANDROID_SINGLETON_STATIC_INSTANCE( BufferMapper )
BufferMapper::BufferMapper()
: mAllocMod(0)

View File

@@ -50,8 +50,7 @@ namespace android {
// SurfaceBuffer
// ============================================================================
template<class SurfaceBuffer> Mutex Singleton<SurfaceBuffer>::sLock;
template<> SurfaceBuffer* Singleton<SurfaceBuffer>::sInstance(0);
ANDROID_SINGLETON_STATIC_INSTANCE( SurfaceBuffer )
SurfaceBuffer::SurfaceBuffer()
: BASE(), handle(0), mOwner(false)