diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 20:42:00 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 20:42:00 +0000 |
commit | 5a70945ddd036b8079987954123ff8f382c285af (patch) | |
tree | 3bb2d0ee55d6732edc13c04d4f63050deea157e3 /src/lazy | |
parent | 2a5cd60bfff32c92cf44a8cfc3e8c017b9aee456 (diff) |
Port most uses of SkOnce to SkLazyPtr.
BUG=skia:
R=reed@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/304383005
git-svn-id: http://skia.googlecode.com/svn/trunk@15006 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy')
-rw-r--r-- | src/lazy/SkDiscardableMemoryPool.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp index 4fb8ae4fe1..1d63a0bad7 100644 --- a/src/lazy/SkDiscardableMemoryPool.cpp +++ b/src/lazy/SkDiscardableMemoryPool.cpp @@ -7,7 +7,7 @@ #include "SkDiscardableMemory.h" #include "SkDiscardableMemoryPool.h" -#include "SkOnce.h" +#include "SkLazyPtr.h" #include "SkTInternalLList.h" #include "SkThread.h" @@ -248,27 +248,20 @@ void DiscardableMemoryPool::dumpPool() { //////////////////////////////////////////////////////////////////////////////// SK_DECLARE_STATIC_MUTEX(gMutex); -SkDiscardableMemoryPool* gPool = NULL; -void create_global_pool(int) { - SkASSERT(NULL == gPool); - gPool = SkDiscardableMemoryPool::Create( - SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE, &gMutex); -} -void cleanup_global_pool() { - gPool->unref(); +SkDiscardableMemoryPool* create_global_pool() { + return SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE, + &gMutex); } + } // namespace -SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create( - size_t size, SkBaseMutex* mutex) { +SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkBaseMutex* mutex) { return SkNEW_ARGS(DiscardableMemoryPool, (size, mutex)); } SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() { - SK_DECLARE_STATIC_ONCE(create_pool_once); - SkOnce(&create_pool_once, create_global_pool, 0, &cleanup_global_pool); - SkASSERT(NULL != gPool); - return gPool; + SK_DECLARE_STATIC_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool); + return global.get(); } // defined in SkImageGenerator.h |