2013-10-16 13:02:15 +00:00
|
|
|
#include "DMTaskRunner.h"
|
|
|
|
#include "DMTask.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
TaskRunner::TaskRunner(int cpuThreads, int gpuThreads) : fCpu(cpuThreads), fGpu(gpuThreads) {}
|
2014-02-26 16:31:22 +00:00
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void TaskRunner::add(CpuTask* task) { fCpu.add(task); }
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void TaskRunner::add(GpuTask* task) { fGpu.add(task); }
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
void TaskRunner::wait() {
|
2014-02-28 20:31:31 +00:00
|
|
|
// 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.
|
2013-10-16 13:02:15 +00:00
|
|
|
fGpu.wait();
|
2014-02-28 20:31:31 +00:00
|
|
|
fCpu.wait();
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|