Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #include "DMTaskRunner.h" | |
| 2 #include "DMTask.h" | |
| 3 | |
| 4 namespace DM { | |
| 5 | |
| 6 TaskRunner::TaskRunner(int cputhreads, int gpuThreads) | |
| 7 : fMain(SkNEW_ARGS(SkThreadPool, (cputhreads))) | |
| 8 , fGpu(SkNEW_ARGS(SkThreadPool, (gpuThreads))) | |
| 9 {} | |
| 10 | |
| 11 void TaskRunner::add(Task* task) { | |
| 12 if (task->usesGpu()) { | |
| 13 fGpu->add(task); | |
| 14 } else { | |
| 15 fMain->add(task); | |
| 16 } | |
| 17 } | |
| 18 | |
| 19 void TaskRunner::wait() { | |
| 20 // These free calls block until the threadpool is done. We don't allow | |
|
epoger
2013/10/11 21:13:13
Thanks for the commentary!
| |
| 21 // children to spawn new GPU tasks so we can wait for that first knowing | |
| 22 // we'll never try to add to it later. Same can't be said of fMain: fGpu | |
| 23 // and fMain can both add tasks to fMain, so we have to wait for that last. | |
| 24 fGpu.free(); | |
| 25 fMain.free(); | |
| 26 } | |
| 27 | |
| 28 } // namespace DM | |
| OLD | NEW |