10a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger#include "DMTaskRunner.h" 20a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger#include "DMTask.h" 30a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger 40a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenbergernamespace DM { 50a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger 60a657bbc2c6fc9daf699942e023050536d5ec95fDerek SollenbergerTaskRunner::TaskRunner(int cputhreads, int gpuThreads) 70a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger : fMain(cputhreads) 80a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger , fGpu(gpuThreads) 90a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger {} 100a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger 110a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenbergervoid TaskRunner::add(Task* task) { 120a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger if (task->usesGpu()) { 130a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger fGpu.add(task); 140a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger } else { 150a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger fMain.add(task); 160a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger } 170a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger} 180a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger 190a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenbergervoid TaskRunner::wait() { 200a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger // These wait calls block until the threadpool is done. We don't allow 210a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger // children to spawn new GPU tasks so we can wait for that first knowing 220a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger // we'll never try to add to it later. Same can't be said of fMain: fGpu 230a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger // and fMain can both add tasks to fMain, so we have to wait for that last. 240a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger fGpu.wait(); 250a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger fMain.wait(); 260a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger} 270a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger 280a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger} // namespace DM 29