mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #ifndef DMTaskRunner_DEFINED |
| 2 | #define DMTaskRunner_DEFINED |
| 3 | |
| 4 | #include "SkThreadPool.h" |
| 5 | #include "SkTypes.h" |
| 6 | |
| 7 | // TaskRunner runs Tasks on one of two threadpools depending on the Task's usesGpu() method. |
| 8 | // This lets us drive the GPU with a small number of threads (e.g. 2 or 4 can be faster than 1) |
| 9 | // while not swamping it with requests from the full fleet of threads that CPU-bound tasks run on. |
| 10 | |
| 11 | namespace DM { |
| 12 | |
| 13 | class Task; |
| 14 | |
| 15 | class TaskRunner : SkNoncopyable { |
| 16 | public: |
| 17 | TaskRunner(int cputhreads, int gpuThreads); |
| 18 | |
| 19 | void add(Task* task); |
| 20 | void wait(); |
| 21 | |
| 22 | private: |
| 23 | SkThreadPool fMain, fGpu; |
| 24 | }; |
| 25 | |
| 26 | } // namespace DM |
| 27 | |
| 28 | #endif // DMTaskRunner_DEFINED |