Home | History | Annotate | Download | only in dm
      1 #include "DMTaskRunner.h"
      2 #include "DMTask.h"
      3 
      4 namespace DM {
      5 
      6 TaskRunner::TaskRunner(int cputhreads, int gpuThreads)
      7     : fMain(cputhreads)
      8     , fGpu(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 wait calls block until the threadpool is done.  We don't allow
     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.wait();
     25     fMain.wait();
     26 }
     27 
     28 }  // namespace DM
     29