diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-31 00:15:22 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-31 00:15:22 +0000 |
commit | f71e8fd0c5d2da9795d00a5b81b716ae585be14a (patch) | |
tree | fe05847a2462ba087f532fdd002c076dbdce541b /src/lazy/SkDiscardableMemoryPool.cpp | |
parent | 56f7cca144c539ec01f00d6382fded362ff193a3 (diff) |
Revert of Port most uses of SkOnce to SkLazyPtr. (https://codereview.chromium.org/304383005/)
Reason for revert:
linux x86-64 release segfault in src/ports/SkFontHost_fontconfig.cpp:107
http://108.170.220.120:10117/builders/Test-Ubuntu12-ShuttleA-GTX660-x86_64-Release/builds/905/steps/RunTests/logs/stdio
Original issue's description:
> Port most uses of SkOnce to SkLazyPtr.
>
> BUG=skia:
>
> Committed: http://code.google.com/p/skia/source/detail?r=15006
>
> Committed: http://code.google.com/p/skia/source/detail?r=15014
R=reed@google.com, mtklein@chromium.org
TBR=mtklein@chromium.org, reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/306063004
git-svn-id: http://skia.googlecode.com/svn/trunk@15015 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy/SkDiscardableMemoryPool.cpp')
-rw-r--r-- | src/lazy/SkDiscardableMemoryPool.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp index 1d63a0bad7..4fb8ae4fe1 100644 --- a/src/lazy/SkDiscardableMemoryPool.cpp +++ b/src/lazy/SkDiscardableMemoryPool.cpp @@ -7,7 +7,7 @@ #include "SkDiscardableMemory.h" #include "SkDiscardableMemoryPool.h" -#include "SkLazyPtr.h" +#include "SkOnce.h" #include "SkTInternalLList.h" #include "SkThread.h" @@ -248,20 +248,27 @@ void DiscardableMemoryPool::dumpPool() { //////////////////////////////////////////////////////////////////////////////// SK_DECLARE_STATIC_MUTEX(gMutex); -SkDiscardableMemoryPool* create_global_pool() { - return SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE, - &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(); } - } // 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_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool); - return global.get(); + SK_DECLARE_STATIC_ONCE(create_pool_once); + SkOnce(&create_pool_once, create_global_pool, 0, &cleanup_global_pool); + SkASSERT(NULL != gPool); + return gPool; } // defined in SkImageGenerator.h |