diff options
author | mtklein <mtklein@chromium.org> | 2015-09-09 09:09:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-09 09:09:53 -0700 |
commit | 6c59d80858f453a426df9b07fdf3a8cc01e0b906 (patch) | |
tree | 1fc4c3c03062744c4382a40e608bdb147bebad09 /src/lazy/SkDiscardableMemoryPool.cpp | |
parent | 336cda3fc0e01cd80212e0ac133d65b60824868e (diff) |
Port uses of SkLazyPtr to SkOncePtr.
This gives SkOncePtr a non-trivial destructor that uses std::default_delete
by default. This is overrideable, as seen in SkColorTable.
SK_DECLARE_STATIC_ONCE_PTR still just leaves its pointers hanging at EOP.
BUG=skia:
No public API changes.
TBR=reed@google.com
Committed: https://skia.googlesource.com/skia/+/a1254acdb344174e761f5061c820559dab64a74c
Review URL: https://codereview.chromium.org/1322933005
Diffstat (limited to 'src/lazy/SkDiscardableMemoryPool.cpp')
-rw-r--r-- | src/lazy/SkDiscardableMemoryPool.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp index 17b8c23d95..78c48f50c1 100644 --- a/src/lazy/SkDiscardableMemoryPool.cpp +++ b/src/lazy/SkDiscardableMemoryPool.cpp @@ -8,8 +8,8 @@ #include "SkDiscardableMemory.h" #include "SkDiscardableMemoryPool.h" #include "SkImageGenerator.h" -#include "SkLazyPtr.h" #include "SkMutex.h" +#include "SkOncePtr.h" #include "SkTInternalLList.h" // Note: @@ -246,23 +246,18 @@ void DiscardableMemoryPool::dumpPool() { this->dumpDownTo(0); } -//////////////////////////////////////////////////////////////////////////////// -SK_DECLARE_STATIC_MUTEX(gMutex); -SkDiscardableMemoryPool* create_global_pool() { - return SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE, - &gMutex); -} - } // namespace SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkBaseMutex* mutex) { return new DiscardableMemoryPool(size, mutex); } -SK_DECLARE_STATIC_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool); +SK_DECLARE_STATIC_MUTEX(gMutex); +SK_DECLARE_STATIC_ONCE_PTR(SkDiscardableMemoryPool, global); SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() { - return global.get(); + return global.get([] { + return SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE, + &gMutex); + }); } - -//////////////////////////////////////////////////////////////////////////////// |