skia2/dm/DMTaskRunner.cpp
mtklein@google.com d36522d12d dm is like gm, but faster and with fewer features.
This is sort of the near-minimal proof-of-concept skeleton.

  - It can run existing GMs.
  - It supports most configs (just not PDF).
  - --replay is the only "fancy" feature it currently supports

Hopefully you will be disturbed by its speed.

BUG=
R=epoger@google.com

Review URL: https://codereview.chromium.org/22839016

git-svn-id: http://skia.googlecode.com/svn/trunk@11802 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-10-16 13:02:15 +00:00

29 lines
700 B
C++

#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