aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMTaskRunner.cpp
blob: e0bd97728871d88b1797a0f9255b45d7e94d405a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "DMTaskRunner.h"
#include "DMTask.h"

namespace DM {

TaskRunner::TaskRunner(int cpuThreads, int gpuThreads) : fCpu(cpuThreads), fGpu(gpuThreads) {}

void TaskRunner::add(CpuTask* task) { fCpu.add(task); }

void TaskRunner::add(GpuTask* task) { fGpu.add(task); }

void TaskRunner::wait() {
    // These wait calls block until each threadpool is done.  We don't allow
    // spawning new child GPU tasks, so we can wait for that first knowing
    // we'll never try to add to it later.  Same can't be said of the CPU pool:
    // both CPU and GPU tasks can spawn off new CPU work, so we wait for that last.
    fGpu.wait();
    fCpu.wait();
}

}  // namespace DM