| OLD | NEW |
| 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 struct LinkedRunnable { | 40 struct LinkedRunnable { |
| 41 // Unowned pointer. | 41 // Unowned pointer. |
| 42 SkRunnable* fRunnable; | 42 SkRunnable* fRunnable; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 SK_DECLARE_INTERNAL_LLIST_INTERFACE(LinkedRunnable); | 45 SK_DECLARE_INTERNAL_LLIST_INTERFACE(LinkedRunnable); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 SkTInternalLList<LinkedRunnable> fQueue; | 48 enum State { |
| 49 SkCondVar fReady; | 49 kRunning_State, // Normal case. We've been constructed and no one has
called wait(). |
| 50 SkTDArray<SkThread*> fThreads; | 50 kWaiting_State, // wait has been called, but there still might be work
to do or being done. |
| 51 bool fDone; | 51 kHalting_State, // There's no work to do and no thread is busy. All th
reads can shut down. |
| 52 }; |
| 53 |
| 54 SkTInternalLList<LinkedRunnable> fQueue; |
| 55 SkCondVar fReady; |
| 56 SkTDArray<SkThread*> fThreads; |
| 57 State fState; |
| 58 int fBusyThreads; |
| 52 | 59 |
| 53 static void Loop(void*); // Static because we pass in this. | 60 static void Loop(void*); // Static because we pass in this. |
| 54 }; | 61 }; |
| 55 | 62 |
| 56 #endif | 63 #endif |
| OLD | NEW |