OLD | NEW |
1 #include "SkTaskGroup.h" | 1 #include "SkTaskGroup.h" |
2 | 2 |
3 #include "SkCondVar.h" | 3 #include "SkCondVar.h" |
4 #include "SkRunnable.h" | 4 #include "SkRunnable.h" |
5 #include "SkTDArray.h" | 5 #include "SkTDArray.h" |
6 #include "SkThread.h" | 6 #include "SkThread.h" |
7 #include "SkThreadUtils.h" | 7 #include "SkThreadUtils.h" |
8 | 8 |
9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
10 static inline int num_cores() { | 10 static inline int num_cores() { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 static ThreadPool* gGlobal; | 159 static ThreadPool* gGlobal; |
160 friend struct SkTaskGroup::Enabler; | 160 friend struct SkTaskGroup::Enabler; |
161 }; | 161 }; |
162 ThreadPool* ThreadPool::gGlobal = NULL; | 162 ThreadPool* ThreadPool::gGlobal = NULL; |
163 | 163 |
164 } // namespace | 164 } // namespace |
165 | 165 |
166 SkTaskGroup::Enabler::Enabler(int threads) { | 166 SkTaskGroup::Enabler::Enabler(int threads) { |
167 SkASSERT(ThreadPool::gGlobal == NULL); | 167 SkASSERT(ThreadPool::gGlobal == NULL); |
168 if (threads != 0) { | 168 if (threads != 0 && SkCondVar::Supported()) { |
169 ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads)); | 169 ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads)); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 SkTaskGroup::Enabler::~Enabler() { | 173 SkTaskGroup::Enabler::~Enabler() { |
174 SkDELETE(ThreadPool::gGlobal); | 174 SkDELETE(ThreadPool::gGlobal); |
175 } | 175 } |
176 | 176 |
177 SkTaskGroup::SkTaskGroup() : fPending(0) {} | 177 SkTaskGroup::SkTaskGroup() : fPending(0) {} |
178 | 178 |
179 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending
); } | 179 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending
); } |
180 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe
nding); } | 180 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe
nding); } |
181 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, &
fPending); } | 181 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, &
fPending); } |
182 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) { | 182 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) { |
183 ThreadPool::Batch(fn, args, N, stride, &fPending); | 183 ThreadPool::Batch(fn, args, N, stride, &fPending); |
184 } | 184 } |
185 | 185 |
OLD | NEW |