blob: 8a0bc838e174d96b0c87986e3a4af89725a8b93d [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMTaskRunner.h"
2#include "DMTask.h"
3
4namespace DM {
5
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +00006TaskRunner::TaskRunner(int cpuThreads, int gpuThreads) : fCpu(cpuThreads), fGpu(gpuThreads) {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00007
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +00008void TaskRunner::add(CpuTask* task) { fCpu.add(task); }
commit-bot@chromium.org3f032152014-05-01 17:41:32 +00009void TaskRunner::addNext(CpuTask* task) { fCpu.addNext(task); }
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000010void TaskRunner::add(GpuTask* task) { fGpu.add(task); }
mtklein@google.comd36522d2013-10-16 13:02:15 +000011
12void TaskRunner::wait() {
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000013 // These wait calls block until each threadpool is done. We don't allow
14 // spawning new child GPU tasks, so we can wait for that first knowing
15 // we'll never try to add to it later. Same can't be said of the CPU pool:
16 // both CPU and GPU tasks can spawn off new CPU work, so we wait for that last.
mtklein@google.comd36522d2013-10-16 13:02:15 +000017 fGpu.wait();
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000018 fCpu.wait();
mtklein@google.comd36522d2013-10-16 13:02:15 +000019}
20
21} // namespace DM