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

Unified Diff: dm/DMTaskRunner.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: one last sync 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
« no previous file with comments | « dm/DMTaskRunner.h ('k') | dm/DMUtil.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMTaskRunner.cpp
diff --git a/dm/DMTaskRunner.cpp b/dm/DMTaskRunner.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..22269a4d7046739a1689d1b08d33987f3ddafcc6
--- /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(cputhreads)
+ , fGpu(gpuThreads)
+ {}
+
+void TaskRunner::add(Task* task) {
+ if (task->usesGpu()) {
+ fGpu.add(task);
+ } else {
+ fMain.add(task);
+ }
+}
+
+void TaskRunner::wait() {
+ // These wait calls block until the threadpool is done. We don't allow
+ // 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.wait();
+ fMain.wait();
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMTaskRunner.h ('k') | dm/DMUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698