aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTaskGroup.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-29 14:17:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-29 14:17:13 -0700
commite71cd54ed4d83310d718490d40643c35b622b9f5 (patch)
tree121583f7bf0092c4d082bc6f50c789ceff8bef96 /src/core/SkTaskGroup.h
parent6838d854a87e79f1fbb7b89b9f395155ad44dc0a (diff)
SkTaskGroup::batch(fn, args, N)
Porting QuiltTask isn't important in itself; this is mostly an API feeler. BUG=skia: Review URL: https://codereview.chromium.org/689673003
Diffstat (limited to 'src/core/SkTaskGroup.h')
-rw-r--r--src/core/SkTaskGroup.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/SkTaskGroup.h b/src/core/SkTaskGroup.h
index 75443c37cb..14a52c6aac 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;
};