aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTaskGroup.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-10-29 12:36:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-29 12:36:45 -0700
commit89889b69391a730f0ba2a1efb549864b7762263f (patch)
tree85e8cb00c41ae79cf4a693491138acd7853b0dfb /src/core/SkTaskGroup.h
parent8f3937d9fcb28018ec14db6697d41b645716d589 (diff)
MultiPictureDraw is taskgroup aware.
SampleApp is multipicturedraw aware. BUG=skia: Review URL: https://codereview.chromium.org/684923002
Diffstat (limited to 'src/core/SkTaskGroup.h')
-rw-r--r--src/core/SkTaskGroup.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/SkTaskGroup.h b/src/core/SkTaskGroup.h
new file mode 100644
index 0000000000..75443c37cb
--- /dev/null
+++ b/src/core/SkTaskGroup.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkTaskGroup_DEFINED
+#define SkTaskGroup_DEFINED
+
+#include "SkTypes.h"
+
+struct SkRunnable;
+
+class SkTaskGroup : SkNoncopyable {
+public:
+ // Create one of these in main() to enable SkTaskGroups globally.
+ struct Enabler : SkNoncopyable {
+ explicit Enabler(int threads = -1); // Default is system-reported core count.
+ ~Enabler();
+ };
+
+ SkTaskGroup();
+ ~SkTaskGroup() { this->wait(); }
+
+ // 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);
+
+ // Block until all Tasks previously add()ed to this SkTaskGroup have run.
+ // You may safely reuse this SkTaskGroup after wait() returns.
+ void wait();
+
+private:
+ /*atomic*/ int32_t fPending;
+};
+
+#endif//SkTaskGroup_DEFINED