OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkTaskGroup_DEFINED |
| 9 #define SkTaskGroup_DEFINED |
| 10 |
| 11 #include "SkTypes.h" |
| 12 #include "SkRunnable.h" |
| 13 |
| 14 class SkTaskGroup : SkNoncopyable { |
| 15 public: |
| 16 // Call before creating any SkTaskGroup to set the number of threads all SkT
askGroups share. |
| 17 // If not called, we default to the number of system-reported cores. |
| 18 static void SetThreadCount(int); |
| 19 |
| 20 SkTaskGroup(); |
| 21 ~SkTaskGroup() { this->wait(); } |
| 22 |
| 23 // Add a task to this SkTaskGroup. It will likely run() on another thread. |
| 24 void add(SkRunnable*); |
| 25 |
| 26 // Block until all Tasks previously add()ed to this SkTaskGroup have run(). |
| 27 // You may safely reuse this SkTaskGroup after wait() returns. |
| 28 void wait(); |
| 29 |
| 30 private: |
| 31 /*atomic*/ int32_t fPending; |
| 32 }; |
| 33 |
| 34 #endif//SkTaskGroup_DEFINED |
OLD | NEW |