aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lazy
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-05-04 14:40:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-04 14:40:18 -0700
commit9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02 (patch)
tree34a4f19d22263c547d2a53734caf179797fb9b53 /src/lazy
parentf2509381bdd9e712919418f7ebe831f974208154 (diff)
SkOncePtr -> SkOnce
It's always nice to kill off a synchronization primitive. And while less terse, I think this new code reads more clearly. ... and, SkOncePtr's tests were the only thing now using sk_num_cores() outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review-Url: https://codereview.chromium.org/1953533002
Diffstat (limited to 'src/lazy')
-rw-r--r--src/lazy/SkDiscardableMemoryPool.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp
index 2be4c755f1..d6753def9d 100644
--- a/src/lazy/SkDiscardableMemoryPool.cpp
+++ b/src/lazy/SkDiscardableMemoryPool.cpp
@@ -9,7 +9,7 @@
#include "SkDiscardableMemoryPool.h"
#include "SkImageGenerator.h"
#include "SkMutex.h"
-#include "SkOncePtr.h"
+#include "SkOnce.h"
#include "SkTInternalLList.h"
// Note:
@@ -245,11 +245,13 @@ SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkMutex* m
}
SK_DECLARE_STATIC_MUTEX(gMutex);
-SK_DECLARE_STATIC_ONCE_PTR(SkDiscardableMemoryPool, global);
SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() {
- return global.get([] {
- return SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE,
- &gMutex);
+ static SkOnce once;
+ static SkDiscardableMemoryPool* global;
+ once([]{
+ global = SkDiscardableMemoryPool::Create(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE,
+ &gMutex);
});
+ return global;
}