diff options
author | 2016-01-04 19:13:19 -0800 | |
---|---|---|
committer | 2016-01-04 19:13:19 -0800 | |
commit | 279c7864090a7b96c34c3594e38ced35967c673f (patch) | |
tree | 3ecd209f1ca5798f6b3d491f9bcd683609b8ca52 /src/core/SkTaskGroup.cpp | |
parent | c4a0d73e9aebcb7d291aa3eb8d5b6926d9a0b77e (diff) |
If we swap its arguments, SkTaskGroup::batch() _is_ sk_parallel_for.
Why have two names if we can get away with one?
This kills off sk_parallel_for_thread_count(), which was only used to avoid forcing a deadlock in OncePtrTest on multicore machines in singlethreaded mode... a really niche use case. Instead just don't explicitly force a race.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1552093002
Review URL: https://codereview.chromium.org/1552093002
Diffstat (limited to 'src/core/SkTaskGroup.cpp')
-rw-r--r-- | src/core/SkTaskGroup.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp index e6b8532bb0..1799256d6f 100644 --- a/src/core/SkTaskGroup.cpp +++ b/src/core/SkTaskGroup.cpp @@ -54,12 +54,12 @@ public: gGlobal->add(fn, pending); } - static void Batch(std::function<void(int)> fn, int N, SkAtomic<int32_t>* pending) { + static void Batch(int N, std::function<void(int)> fn, SkAtomic<int32_t>* pending) { if (!gGlobal) { for (int i = 0; i < N; i++) { fn(i); } return; } - gGlobal->batch(fn, N, pending); + gGlobal->batch(N, fn, pending); } static void Wait(SkAtomic<int32_t>* pending) { @@ -142,7 +142,7 @@ private: fWorkAvailable.signal(1); } - void batch(std::function<void(int)> fn, int N, SkAtomic<int32_t>* pending) { + void batch(int N, std::function<void(int)> fn, SkAtomic<int32_t>* pending) { pending->fetch_add(+N, sk_memory_order_relaxed); // No barrier needed. { AutoLock lock(&fWorkLock); @@ -196,7 +196,6 @@ private: static ThreadPool* gGlobal; friend struct SkTaskGroup::Enabler; - friend int ::sk_parallel_for_thread_count(); }; ThreadPool* ThreadPool::gGlobal = nullptr; @@ -216,13 +215,7 @@ SkTaskGroup::SkTaskGroup() : fPending(0) {} void SkTaskGroup::wait() { ThreadPool::Wait(&fPending); } void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPending); } void SkTaskGroup::add(std::function<void(void)> fn) { ThreadPool::Add(fn, &fPending); } -void SkTaskGroup::batch (std::function<void(int)> fn, int N) { - ThreadPool::Batch(fn, N, &fPending); +void SkTaskGroup::batch(int N, std::function<void(int)> fn) { + ThreadPool::Batch(N, fn, &fPending); } -int sk_parallel_for_thread_count() { - if (ThreadPool::gGlobal != nullptr) { - return ThreadPool::gGlobal->fThreads.count(); - } - return 0; -} |