Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Unified Diff: src/lazy/SkDiscardableMemoryPool.cpp

Issue 306063004: Revert of Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/fonts/SkRemotableFontMgr.cpp ('k') | src/ports/SkFontConfigInterface_direct.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkDiscardableMemoryPool.cpp
diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp
index 1d63a0bad710985b7dc2ab127554e77906075753..4fb8ae4fe1fbc626453bf6eecd009dac5183b9fa 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 @@
////////////////////////////////////////////////////////////////////////////////
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
« no previous file with comments | « src/fonts/SkRemotableFontMgr.cpp ('k') | src/ports/SkFontConfigInterface_direct.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698