Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b1927f6 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

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.
parent f670127a
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,18 @@ private:
    static TYPE* sInstance;
    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
}; // namespace android


+1 −2
Original line number Original line Diff line number Diff line
@@ -34,8 +34,7 @@
namespace android {
namespace android {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


template<class BufferAllocator> Mutex Singleton<BufferAllocator>::sLock; 
ANDROID_SINGLETON_STATIC_INSTANCE( BufferAllocator )
template<> BufferAllocator* Singleton<BufferAllocator>::sInstance(0); 


Mutex BufferAllocator::sLock;
Mutex BufferAllocator::sLock;
KeyedVector<buffer_handle_t, BufferAllocator::alloc_rec_t> BufferAllocator::sAllocList;
KeyedVector<buffer_handle_t, BufferAllocator::alloc_rec_t> BufferAllocator::sAllocList;
+1 −2
Original line number Original line Diff line number Diff line
@@ -44,8 +44,7 @@
namespace android {
namespace android {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


template<class BufferMapper> Mutex Singleton<BufferMapper>::sLock; 
ANDROID_SINGLETON_STATIC_INSTANCE( BufferMapper )
template<> BufferMapper* Singleton<BufferMapper>::sInstance(0); 


BufferMapper::BufferMapper()
BufferMapper::BufferMapper()
    : mAllocMod(0)
    : mAllocMod(0)
+1 −2
Original line number Original line Diff line number Diff line
@@ -50,8 +50,7 @@ namespace android {
//  SurfaceBuffer
//  SurfaceBuffer
// ============================================================================
// ============================================================================


template<class SurfaceBuffer> Mutex Singleton<SurfaceBuffer>::sLock; 
ANDROID_SINGLETON_STATIC_INSTANCE( SurfaceBuffer )
template<> SurfaceBuffer* Singleton<SurfaceBuffer>::sInstance(0); 


SurfaceBuffer::SurfaceBuffer() 
SurfaceBuffer::SurfaceBuffer() 
    : BASE(), handle(0), mOwner(false)
    : BASE(), handle(0), mOwner(false)