From ffa4a9213b4e754adc210fa02a3c4b1ae8d3b6d0 Mon Sep 17 00:00:00 2001 From: mtklein Date: Thu, 5 May 2016 16:05:56 -0700 Subject: 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 Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02 Review-Url: https://codereview.chromium.org/1953533002 --- src/lazy/SkDiscardableMemoryPool.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/lazy') diff --git a/src/lazy/SkDiscardableMemoryPool.cpp b/src/lazy/SkDiscardableMemoryPool.cpp index 1f3bcf93e9..6ced5bfc02 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: @@ -246,11 +246,13 @@ SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkBaseMute } 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; } -- cgit v1.2.3