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

Unified Diff: dm/DMTaskRunner.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: missed one Created 7 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
Index: dm/DMTaskRunner.cpp
diff --git a/dm/DMTaskRunner.cpp b/dm/DMTaskRunner.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5661ea2ca79196796f84950df1bbb8516f3aa005
--- /dev/null
+++ b/dm/DMTaskRunner.cpp
@@ -0,0 +1,28 @@
+#include "DMTaskRunner.h"
+#include "DMTask.h"
+
+namespace DM {
+
+TaskRunner::TaskRunner(int cputhreads, int gpuThreads)
+ : fMain(SkNEW_ARGS(SkThreadPool, (cputhreads)))
+ , fGpu(SkNEW_ARGS(SkThreadPool, (gpuThreads)))
+ {}
+
+void TaskRunner::add(Task* task) {
+ if (task->usesGpu()) {
+ fGpu->add(task);
+ } else {
+ fMain->add(task);
+ }
+}
+
+void TaskRunner::wait() {
+ // These free calls block until the threadpool is done. We don't allow
epoger 2013/10/11 21:13:13 Thanks for the commentary!
+ // children to spawn new GPU tasks so we can wait for that first knowing
+ // we'll never try to add to it later. Same can't be said of fMain: fGpu
+ // and fMain can both add tasks to fMain, so we have to wait for that last.
+ fGpu.free();
+ fMain.free();
+}
+
+} // namespace DM

Powered by Google App Engine
This is Rietveld 408576698