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

Unified Diff: src/core/SkTaskGroup.cpp

Issue 1552093002: If we swap its arguments, SkTaskGroup::batch() _is_ sk_parallel_for. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 12 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkTaskGroup.h ('k') | tests/BlendTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTaskGroup.cpp
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp
index e6b8532bb046e5175f4854bee5c2da147aa105e9..1799256d6fe869a6d1fa58987302ecac739afdae 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;
-}
« no previous file with comments | « src/core/SkTaskGroup.h ('k') | tests/BlendTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698