Index: src/core/SkTaskGroup.h |
diff --git a/src/core/SkTaskGroup.h b/src/core/SkTaskGroup.h |
index d1daa444945c6ada116c155a5c9c6cba38dc17f8..e6c36651fd50772a67b417e2044447e6c120fcdb 100644 |
--- a/src/core/SkTaskGroup.h |
+++ b/src/core/SkTaskGroup.h |
@@ -34,7 +34,7 @@ public: |
void add(std::function<void(void)> fn); |
// Add a batch of N tasks, all calling fn with different arguments. |
- void batch(std::function<void(int)> fn, int N); |
+ void batch(int N, std::function<void(int)> fn); |
// Block until all Tasks previously add()ed to this SkTaskGroup have run. |
// You may safely reuse this SkTaskGroup after wait() returns. |
@@ -47,48 +47,4 @@ private: |
// Returns best estimate of number of CPU cores available to use. |
int sk_num_cores(); |
-int sk_parallel_for_thread_count(); |
- |
-// Call f(i) for i in [0, end). |
-template <typename Func> |
-void sk_parallel_for(int end, const Func& f) { |
- if (end <= 0) { return; } |
- |
- struct Chunk { |
- const Func* f; |
- int start, end; |
- }; |
- |
- // TODO(mtklein): this chunking strategy could probably use some tuning. |
- int max_chunks = sk_num_cores() * 2, |
- stride = (end + max_chunks - 1 ) / max_chunks, |
- nchunks = (end + stride - 1 ) / stride; |
- SkASSERT(nchunks <= max_chunks); |
- |
-#if defined(GOOGLE3) |
- // Stack frame size is limited in GOOGLE3. |
- SkAutoSTMalloc<512, Chunk> chunks(nchunks); |
-#else |
- // With the chunking strategy above this won't malloc until we have a machine with >512 cores. |
- SkAutoSTMalloc<1024, Chunk> chunks(nchunks); |
-#endif |
- |
- for (int i = 0; i < nchunks; i++) { |
- Chunk& c = chunks[i]; |
- c.f = &f; |
- c.start = i * stride; |
- c.end = SkTMin(c.start + stride, end); |
- SkASSERT(c.start < c.end); // Nothing will break if start >= end, but it's a wasted chunk. |
- } |
- |
- Chunk* chunkBase = chunks.get(); |
- auto run_chunk = [chunkBase](int i) { |
- Chunk& c = chunkBase[i]; |
- for (int i = c.start; i < c.end; i++) { |
- (*c.f)(i); |
- } |
- }; |
- SkTaskGroup().batch(run_chunk, nchunks); |
-} |
- |
#endif//SkTaskGroup_DEFINED |