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

Side by Side Diff: src/core/SkTaskGroup.h

Issue 1419593004: Avoid hang in OncePtr test with --threads 1 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef SkTaskGroup_DEFINED 8 #ifndef SkTaskGroup_DEFINED
9 #define SkTaskGroup_DEFINED 9 #define SkTaskGroup_DEFINED
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void add (void_fn, void* arg); 47 void add (void_fn, void* arg);
48 void batch(void_fn, void* args, int N, size_t stride); 48 void batch(void_fn, void* args, int N, size_t stride);
49 49
50 SkAtomic<int32_t> fPending; 50 SkAtomic<int32_t> fPending;
51 }; 51 };
52 52
53 // Returns best estimate of number of CPU cores available to use. 53 // Returns best estimate of number of CPU cores available to use.
54 int sk_num_cores(); 54 int sk_num_cores();
55 55
56 int sk_parallel_for_thread_count();
57
56 // Call f(i) for i in [0, end). 58 // Call f(i) for i in [0, end).
57 template <typename Func> 59 template <typename Func>
58 void sk_parallel_for(int end, const Func& f) { 60 void sk_parallel_for(int end, const Func& f) {
59 if (end <= 0) { return; } 61 if (end <= 0) { return; }
60 62
61 struct Chunk { 63 struct Chunk {
62 const Func* f; 64 const Func* f;
63 int start, end; 65 int start, end;
64 }; 66 };
65 67
(...skipping 21 matching lines...) Expand all
87 89
88 void(*run_chunk)(Chunk*) = [](Chunk* c) { 90 void(*run_chunk)(Chunk*) = [](Chunk* c) {
89 for (int i = c->start; i < c->end; i++) { 91 for (int i = c->start; i < c->end; i++) {
90 (*c->f)(i); 92 (*c->f)(i);
91 } 93 }
92 }; 94 };
93 SkTaskGroup().batch(run_chunk, chunks.get(), nchunks); 95 SkTaskGroup().batch(run_chunk, chunks.get(), nchunks);
94 } 96 }
95 97
96 #endif//SkTaskGroup_DEFINED 98 #endif//SkTaskGroup_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698