diff options
author | mtklein <mtklein@chromium.org> | 2016-05-04 14:40:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-04 14:40:18 -0700 |
commit | 9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02 (patch) | |
tree | 34a4f19d22263c547d2a53734caf179797fb9b53 /src/core/SkTaskGroup.cpp | |
parent | f2509381bdd9e712919418f7ebe831f974208154 (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/core/SkTaskGroup.cpp')
-rw-r--r-- | src/core/SkTaskGroup.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp index 2ae1b59971..7a58c865a7 100644 --- a/src/core/SkTaskGroup.cpp +++ b/src/core/SkTaskGroup.cpp @@ -14,25 +14,25 @@ #include "SkThreadUtils.h" #if defined(SK_BUILD_FOR_WIN32) - static void query_num_cores(int* num_cores) { + static void query_num_cores(int* cores) { SYSTEM_INFO sysinfo; GetNativeSystemInfo(&sysinfo); - *num_cores = sysinfo.dwNumberOfProcessors; + *cores = sysinfo.dwNumberOfProcessors; } #else #include <unistd.h> - static void query_num_cores(int* num_cores) { - *num_cores = (int)sysconf(_SC_NPROCESSORS_ONLN); + static void query_num_cores(int* cores) { + *cores = (int)sysconf(_SC_NPROCESSORS_ONLN); } #endif -int sk_num_cores() { - // We cache sk_num_cores() so we only query the OS once. - static int num_cores = 0; +static int num_cores() { + // We cache num_cores() so we only query the OS once. + static int cores = 0; static SkOnce once; - once(query_num_cores, &num_cores); - SkASSERT(num_cores > 0); - return num_cores; + once(query_num_cores, &cores); + SkASSERT(cores > 0); + return cores; } namespace { @@ -98,7 +98,7 @@ private: explicit ThreadPool(int threads) { if (threads == -1) { - threads = sk_num_cores(); + threads = num_cores(); } for (int i = 0; i < threads; i++) { fThreads.push(new SkThread(&ThreadPool::Loop, this)); |