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

Side by Side Diff: include/utils/SkThreadPool.h

Issue 26470005: SkThreadPool: tweak two little things that have been annoying me (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reup Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/utils/SkThreadPool.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 2012 Google Inc. 2 * Copyright 2012 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 SkThreadPool_DEFINED 8 #ifndef SkThreadPool_DEFINED
9 #define SkThreadPool_DEFINED 9 #define SkThreadPool_DEFINED
10 10
11 #include "SkCondVar.h" 11 #include "SkCondVar.h"
12 #include "SkRunnable.h"
12 #include "SkTDArray.h" 13 #include "SkTDArray.h"
13 #include "SkTInternalLList.h" 14 #include "SkTInternalLList.h"
14 15
15 class SkRunnable;
16 class SkThread; 16 class SkThread;
17 17
18 class SkThreadPool { 18 class SkThreadPool {
19 19
20 public: 20 public:
21 /** 21 /**
22 * Create a threadpool with count threads, or one thread per core if kThread PerCore. 22 * Create a threadpool with count threads, or one thread per core if kThread PerCore.
23 */ 23 */
24 static const int kThreadPerCore = -1; 24 static const int kThreadPerCore = -1;
25 explicit SkThreadPool(int count); 25 explicit SkThreadPool(int count);
26 ~SkThreadPool(); 26 ~SkThreadPool();
27 27
28 /** 28 /**
29 * Queues up an SkRunnable to run when a thread is available, or immediately if 29 * Queues up an SkRunnable to run when a thread is available, or immediately if
30 * count is 0. NULL is a safe no-op. Does not take ownership. 30 * count is 0. NULL is a safe no-op. Does not take ownership.
31 */ 31 */
32 void add(SkRunnable*); 32 void add(SkRunnable*);
33 33
34 /**
35 * Block until all added SkRunnables have completed. Once called, calling a dd() is undefined.
36 */
37 void wait();
38
34 private: 39 private:
35 struct LinkedRunnable { 40 struct LinkedRunnable {
36 // Unowned pointer. 41 // Unowned pointer.
37 SkRunnable* fRunnable; 42 SkRunnable* fRunnable;
38 43
39 private: 44 private:
40 SK_DECLARE_INTERNAL_LLIST_INTERFACE(LinkedRunnable); 45 SK_DECLARE_INTERNAL_LLIST_INTERFACE(LinkedRunnable);
41 }; 46 };
42 47
43 SkTInternalLList<LinkedRunnable> fQueue; 48 SkTInternalLList<LinkedRunnable> fQueue;
44 SkCondVar fReady; 49 SkCondVar fReady;
45 SkTDArray<SkThread*> fThreads; 50 SkTDArray<SkThread*> fThreads;
46 bool fDone; 51 bool fDone;
47 52
48 static void Loop(void*); // Static because we pass in this. 53 static void Loop(void*); // Static because we pass in this.
49 }; 54 };
50 55
51 #endif 56 #endif
OLDNEW
« no previous file with comments | « no previous file | src/utils/SkThreadPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698