blob: b20113f506023be422dd9262cdf32dd43f6796d2 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#ifndef DMTaskRunner_DEFINED
2#define DMTaskRunner_DEFINED
3
commit-bot@chromium.org787227d2014-03-26 21:26:15 +00004#include "DMGpuSupport.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00005#include "SkThreadPool.h"
6#include "SkTypes.h"
7
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +00008// TaskRunner runs Tasks on one of two threadpools depending on the need for a GrContextFactory.
9// It's typically a good idea to run fewer GPU threads than CPU threads (go nuts with those).
mtklein@google.comd36522d2013-10-16 13:02:15 +000010
11namespace DM {
12
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000013class CpuTask;
14class GpuTask;
mtklein@google.comd36522d2013-10-16 13:02:15 +000015
16class TaskRunner : SkNoncopyable {
17public:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000018 explicit TaskRunner(int cpuThreads, int gpuThreads);
mtklein@google.comd36522d2013-10-16 13:02:15 +000019
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000020 void add(CpuTask* task);
21 void add(GpuTask* task);
mtklein@google.comd36522d2013-10-16 13:02:15 +000022 void wait();
23
24private:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000025 SkTThreadPool<void> fCpu;
26 SkTThreadPool<GrContextFactory> fGpu;
mtklein@google.comd36522d2013-10-16 13:02:15 +000027};
28
29} // namespace DM
30
31#endif // DMTaskRunner_DEFINED