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

Unified Diff: src/core/SkTaskGroup.h

Issue 689673003: SkTaskGroup::batch(fn, args, N) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pun fn pointers Created 6 years, 2 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/SkMultiPictureDraw.cpp ('k') | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTaskGroup.h
diff --git a/src/core/SkTaskGroup.h b/src/core/SkTaskGroup.h
index 75443c37cbaf44a371169ff01997d0b221a0e63c..14a52c6aac1aadd1d3393466200fec43f4bf0e45 100644
--- a/src/core/SkTaskGroup.h
+++ b/src/core/SkTaskGroup.h
@@ -26,13 +26,25 @@ public:
// Add a task to this SkTaskGroup. It will likely run on another thread.
// Neither add() method takes owership of any of its parameters.
void add(SkRunnable*);
- void add(void (*fn)(void*), void* arg);
+
+ template <typename T>
+ void add(void (*fn)(T*), T* arg) { this->add((void_fn)fn, (void*)arg); }
+
+ // Add a batch of N tasks, all calling fn with different arguments.
+ // Equivalent to a loop over add(fn, arg), but with perhaps less synchronization overhead.
+ template <typename T>
+ void batch(void (*fn)(T*), T* args, int N) { this->batch((void_fn)fn, args, N, sizeof(T)); }
// Block until all Tasks previously add()ed to this SkTaskGroup have run.
// You may safely reuse this SkTaskGroup after wait() returns.
void wait();
private:
+ typedef void(*void_fn)(void*);
+
+ void add (void_fn, void* arg);
+ void batch(void_fn, void* args, int N, size_t stride);
+
/*atomic*/ int32_t fPending;
};
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698