OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkTaskGroup_DEFINED | 8 #ifndef SkTaskGroup_DEFINED |
9 #define SkTaskGroup_DEFINED | 9 #define SkTaskGroup_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include "SkAtomics.h" |
12 | 13 |
13 struct SkRunnable; | 14 struct SkRunnable; |
14 | 15 |
15 class SkTaskGroup : SkNoncopyable { | 16 class SkTaskGroup : SkNoncopyable { |
16 public: | 17 public: |
17 // Create one of these in main() to enable SkTaskGroups globally. | 18 // Create one of these in main() to enable SkTaskGroups globally. |
18 struct Enabler : SkNoncopyable { | 19 struct Enabler : SkNoncopyable { |
19 explicit Enabler(int threads = -1); // Default is system-reported core
count. | 20 explicit Enabler(int threads = -1); // Default is system-reported core
count. |
20 ~Enabler(); | 21 ~Enabler(); |
21 }; | 22 }; |
(...skipping 16 matching lines...) Expand all Loading... |
38 // Block until all Tasks previously add()ed to this SkTaskGroup have run. | 39 // Block until all Tasks previously add()ed to this SkTaskGroup have run. |
39 // You may safely reuse this SkTaskGroup after wait() returns. | 40 // You may safely reuse this SkTaskGroup after wait() returns. |
40 void wait(); | 41 void wait(); |
41 | 42 |
42 private: | 43 private: |
43 typedef void(*void_fn)(void*); | 44 typedef void(*void_fn)(void*); |
44 | 45 |
45 void add (void_fn, void* arg); | 46 void add (void_fn, void* arg); |
46 void batch(void_fn, void* args, int N, size_t stride); | 47 void batch(void_fn, void* args, int N, size_t stride); |
47 | 48 |
48 /*atomic*/ int32_t fPending; | 49 SkAtomic<int32_t> fPending; |
49 }; | 50 }; |
50 | 51 |
51 #endif//SkTaskGroup_DEFINED | 52 #endif//SkTaskGroup_DEFINED |
OLD | NEW |