OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkOnce.h" | 8 #include "SkOnce.h" |
9 #include "SkRunnable.h" | 9 #include "SkRunnable.h" |
10 #include "SkSemaphore.h" | 10 #include "SkSemaphore.h" |
11 #include "SkSpinlock.h" | 11 #include "SkSpinlock.h" |
12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
13 #include "SkTaskGroup.h" | 13 #include "SkTaskGroup.h" |
14 #include "SkThreadUtils.h" | 14 #include "SkThreadUtils.h" |
15 | 15 |
16 #if defined(SK_BUILD_FOR_WIN32) | 16 #if defined(SK_BUILD_FOR_WIN32) |
17 static void query_num_cores(int* num_cores) { | 17 static void query_num_cores(int* num_cores) { |
18 SYSTEM_INFO sysinfo; | 18 SYSTEM_INFO sysinfo; |
19 GetSystemInfo(&sysinfo); | 19 GetNativeSystemInfo(&sysinfo); |
20 *num_cores = sysinfo.dwNumberOfProcessors; | 20 *num_cores = sysinfo.dwNumberOfProcessors; |
21 } | 21 } |
22 #else | 22 #else |
23 #include <unistd.h> | 23 #include <unistd.h> |
24 static void query_num_cores(int* num_cores) { | 24 static void query_num_cores(int* num_cores) { |
25 *num_cores = (int)sysconf(_SC_NPROCESSORS_ONLN); | 25 *num_cores = (int)sysconf(_SC_NPROCESSORS_ONLN); |
26 } | 26 } |
27 #endif | 27 #endif |
28 | 28 |
29 // We cache sk_num_cores() so we only query the OS once. | 29 // We cache sk_num_cores() so we only query the OS once. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 SkTaskGroup::SkTaskGroup() : fPending(0) {} | 215 SkTaskGroup::SkTaskGroup() : fPending(0) {} |
216 | 216 |
217 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending
); } | 217 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending
); } |
218 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe
nding); } | 218 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe
nding); } |
219 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, &
fPending); } | 219 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, &
fPending); } |
220 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) { | 220 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) { |
221 ThreadPool::Batch(fn, args, N, stride, &fPending); | 221 ThreadPool::Batch(fn, args, N, stride, &fPending); |
222 } | 222 } |
223 | 223 |
OLD | NEW |