DMTaskRunner.cpp revision ef57b7e65330d5f794a513630517907500f1c1d0
1#include "DMTaskRunner.h" 2#include "DMTask.h" 3 4namespace DM { 5 6TaskRunner::TaskRunner(int cpuThreads, int gpuThreads) : fCpu(cpuThreads), fGpu(gpuThreads) {} 7 8void TaskRunner::add(CpuTask* task) { fCpu.add(task); } 9 10void TaskRunner::add(GpuTask* task) { fGpu.add(task); } 11 12void TaskRunner::wait() { 13 // 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. 17 fGpu.wait(); 18 fCpu.wait(); 19} 20 21} // namespace DM 22