Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: src/core/SkTaskGroup.h

Issue 1705583003: clean up more dead code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gyp/utils.gypi ('k') | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <functional> 11 #include <functional>
12 12
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 #include "SkAtomics.h" 14 #include "SkAtomics.h"
15 #include "SkTemplates.h" 15 #include "SkTemplates.h"
16 16
17 struct SkRunnable;
18
19 class SkTaskGroup : SkNoncopyable { 17 class SkTaskGroup : SkNoncopyable {
20 public: 18 public:
21 // Create one of these in main() to enable SkTaskGroups globally. 19 // Create one of these in main() to enable SkTaskGroups globally.
22 struct Enabler : SkNoncopyable { 20 struct Enabler : SkNoncopyable {
23 explicit Enabler(int threads = -1); // Default is system-reported core count. 21 explicit Enabler(int threads = -1); // Default is system-reported core count.
24 ~Enabler(); 22 ~Enabler();
25 }; 23 };
26 24
27 SkTaskGroup(); 25 SkTaskGroup();
28 ~SkTaskGroup() { this->wait(); } 26 ~SkTaskGroup() { this->wait(); }
29 27
30 // Add a task to this SkTaskGroup. It will likely run on another thread. 28 // Add a task to this SkTaskGroup. It will likely run on another thread.
31 // Neither add() method takes owership of any of its parameters.
32 void add(SkRunnable*);
33
34 void add(std::function<void(void)> fn); 29 void add(std::function<void(void)> fn);
35 30
36 // Add a batch of N tasks, all calling fn with different arguments. 31 // Add a batch of N tasks, all calling fn with different arguments.
37 void batch(int N, std::function<void(int)> fn); 32 void batch(int N, std::function<void(int)> fn);
38 33
39 // Block until all Tasks previously add()ed to this SkTaskGroup have run. 34 // Block until all Tasks previously add()ed to this SkTaskGroup have run.
40 // You may safely reuse this SkTaskGroup after wait() returns. 35 // You may safely reuse this SkTaskGroup after wait() returns.
41 void wait(); 36 void wait();
42 37
43 private: 38 private:
44 SkAtomic<int32_t> fPending; 39 SkAtomic<int32_t> fPending;
45 }; 40 };
46 41
47 // Returns best estimate of number of CPU cores available to use. 42 // Returns best estimate of number of CPU cores available to use.
48 int sk_num_cores(); 43 int sk_num_cores();
49 44
50 #endif//SkTaskGroup_DEFINED 45 #endif//SkTaskGroup_DEFINED
OLDNEW
« no previous file with comments | « gyp/utils.gypi ('k') | src/core/SkTaskGroup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698