aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMTaskRunner.h
blob: b20113f506023be422dd9262cdf32dd43f6796d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef DMTaskRunner_DEFINED
#define DMTaskRunner_DEFINED

#include "DMGpuSupport.h"
#include "SkThreadPool.h"
#include "SkTypes.h"

// TaskRunner runs Tasks on one of two threadpools depending on the need for a GrContextFactory.
// It's typically a good idea to run fewer GPU threads than CPU threads (go nuts with those).

namespace DM {

class CpuTask;
class GpuTask;

class TaskRunner : SkNoncopyable {
public:
    explicit TaskRunner(int cpuThreads, int gpuThreads);

    void add(CpuTask* task);
    void add(GpuTask* task);
    void wait();

private:
    SkTThreadPool<void> fCpu;
    SkTThreadPool<GrContextFactory> fGpu;
};

}  // namespace DM

#endif  // DMTaskRunner_DEFINED