OLD | NEW |
1 #include "DMTaskRunner.h" | 1 #include "DMTaskRunner.h" |
2 #include "DMTask.h" | 2 #include "DMTask.h" |
3 | 3 |
4 namespace DM { | 4 namespace DM { |
5 | 5 |
6 void TaskRunner::add(CpuTask* task) { fCpuWork.add(task); } | 6 TaskRunner::TaskRunner(int cpuThreads, int gpuThreads) : fCpu(cpuThreads), fGpu(
gpuThreads) {} |
7 void TaskRunner::add(GpuTask* task) { fGpuWork.push(task); } | 7 |
| 8 void TaskRunner::add(CpuTask* task) { fCpu.add(task); } |
| 9 void TaskRunner::addNext(CpuTask* task) { fCpu.addNext(task); } |
| 10 void TaskRunner::add(GpuTask* task) { fGpu.add(task); } |
8 | 11 |
9 void TaskRunner::wait() { | 12 void TaskRunner::wait() { |
10 GrContextFactory factory; | 13 // These wait calls block until each threadpool is done. We don't allow |
11 for (int i = 0; i < fGpuWork.count(); i++) { | 14 // spawning new child GPU tasks, so we can wait for that first knowing |
12 fGpuWork[i]->run(&factory); | 15 // we'll never try to add to it later. Same can't be said of the CPU pool: |
13 } | 16 // both CPU and GPU tasks can spawn off new CPU work, so we wait for that la
st. |
14 fCpuWork.wait(); | 17 fGpu.wait(); |
| 18 fCpu.wait(); |
15 } | 19 } |
16 | 20 |
17 } // namespace DM | 21 } // namespace DM |
OLD | NEW |