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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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 | « src/core/SkTMultiMap.h ('k') | src/core/SkTypeface.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 #include "SkOnce.h" 8 #include "SkOnce.h"
9 #include "SkRunnable.h" 9 #include "SkRunnable.h"
10 #include "SkSemaphore.h" 10 #include "SkSemaphore.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void (*fn)(void*); // A function to call, 104 void (*fn)(void*); // A function to call,
105 void* arg; // its argument, 105 void* arg; // its argument,
106 SkAtomic<int32_t>* pending; // then decrement pending afterwards. 106 SkAtomic<int32_t>* pending; // then decrement pending afterwards.
107 }; 107 };
108 108
109 explicit ThreadPool(int threads) { 109 explicit ThreadPool(int threads) {
110 if (threads == -1) { 110 if (threads == -1) {
111 threads = sk_num_cores(); 111 threads = sk_num_cores();
112 } 112 }
113 for (int i = 0; i < threads; i++) { 113 for (int i = 0; i < threads; i++) {
114 fThreads.push(SkNEW_ARGS(SkThread, (&ThreadPool::Loop, this))); 114 fThreads.push(new SkThread(&ThreadPool::Loop, this));
115 fThreads.top()->start(); 115 fThreads.top()->start();
116 } 116 }
117 } 117 }
118 118
119 ~ThreadPool() { 119 ~ThreadPool() {
120 SkASSERT(fWork.isEmpty()); // All SkTaskGroups should be destroyed by n ow. 120 SkASSERT(fWork.isEmpty()); // All SkTaskGroups should be destroyed by n ow.
121 121
122 // Send a poison pill to each thread. 122 // Send a poison pill to each thread.
123 SkAtomic<int> dummy(0); 123 SkAtomic<int> dummy(0);
124 for (int i = 0; i < fThreads.count(); i++) { 124 for (int i = 0; i < fThreads.count(); i++) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 friend struct SkTaskGroup::Enabler; 198 friend struct SkTaskGroup::Enabler;
199 }; 199 };
200 ThreadPool* ThreadPool::gGlobal = NULL; 200 ThreadPool* ThreadPool::gGlobal = NULL;
201 201
202 } // namespace 202 } // namespace
203 203
204 SkTaskGroup::Enabler::Enabler(int threads) { 204 SkTaskGroup::Enabler::Enabler(int threads) {
205 SkASSERT(ThreadPool::gGlobal == NULL); 205 SkASSERT(ThreadPool::gGlobal == NULL);
206 if (threads != 0) { 206 if (threads != 0) {
207 ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads)); 207 ThreadPool::gGlobal = new ThreadPool(threads);
208 } 208 }
209 } 209 }
210 210
211 SkTaskGroup::Enabler::~Enabler() { 211 SkTaskGroup::Enabler::~Enabler() { delete ThreadPool::gGlobal; }
212 SkDELETE(ThreadPool::gGlobal);
213 }
214 212
215 SkTaskGroup::SkTaskGroup() : fPending(0) {} 213 SkTaskGroup::SkTaskGroup() : fPending(0) {}
216 214
217 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending ); } 215 void SkTaskGroup::wait() { ThreadPool::Wait(&fPending ); }
218 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe nding); } 216 void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPe nding); }
219 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, & fPending); } 217 void SkTaskGroup::add(void (*fn)(void*), void* arg) { ThreadPool::Add(fn, arg, & fPending); }
220 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) { 218 void SkTaskGroup::batch (void (*fn)(void*), void* args, int N, size_t stride) {
221 ThreadPool::Batch(fn, args, N, stride, &fPending); 219 ThreadPool::Batch(fn, args, N, stride, &fPending);
222 } 220 }
223 221
OLDNEW
« no previous file with comments | « src/core/SkTMultiMap.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698