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

Unified Diff: include/utils/SkThreadPool.h

Issue 263803003: DM: Push GPU-parent child tasks to the front of the queue. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: share code Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMTaskRunner.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/utils/SkThreadPool.h
diff --git a/include/utils/SkThreadPool.h b/include/utils/SkThreadPool.h
index a75bed8be44f538eeb87d3c21658f2de83290618..295b1b4f080004edb111f51570a5beb74b0371b8 100644
--- a/include/utils/SkThreadPool.h
+++ b/include/utils/SkThreadPool.h
@@ -50,6 +50,11 @@ public:
void add(SkTRunnable<T>*);
/**
+ * Same as add, but adds the runnable as the very next to run rather than enqueueing it.
+ */
+ void addNext(SkTRunnable<T>*);
+
+ /**
* Block until all added SkRunnables have completed. Once called, calling add() is undefined.
*/
void wait();
@@ -66,6 +71,9 @@ public:
kHalting_State, // There's no work to do and no thread is busy. All threads can shut down.
};
+ void addSomewhere(SkTRunnable<T>* r,
+ void (SkTInternalLList<LinkedRunnable>::*)(LinkedRunnable*));
+
SkTInternalLList<LinkedRunnable> fQueue;
SkCondVar fReady;
SkTDArray<SkThread*> fThreads;
@@ -111,7 +119,8 @@ struct ThreadLocal<void> {
} // namespace SkThreadPoolPrivate
template <typename T>
-void SkTThreadPool<T>::add(SkTRunnable<T>* r) {
+void SkTThreadPool<T>::addSomewhere(SkTRunnable<T>* r,
+ void (SkTInternalLList<LinkedRunnable>::* f)(LinkedRunnable*)) {
if (r == NULL) {
return;
}
@@ -126,11 +135,21 @@ void SkTThreadPool<T>::add(SkTRunnable<T>* r) {
linkedRunnable->fRunnable = r;
fReady.lock();
SkASSERT(fState != kHalting_State); // Shouldn't be able to add work when we're halting.
- fQueue.addToHead(linkedRunnable);
+ (fQueue.*f)(linkedRunnable);
fReady.signal();
fReady.unlock();
}
+template <typename T>
+void SkTThreadPool<T>::add(SkTRunnable<T>* r) {
+ this->addSomewhere(r, &SkTInternalLList<LinkedRunnable>::addToTail);
+}
+
+template <typename T>
+void SkTThreadPool<T>::addNext(SkTRunnable<T>* r) {
+ this->addSomewhere(r, &SkTInternalLList<LinkedRunnable>::addToHead);
+}
+
template <typename T>
void SkTThreadPool<T>::wait() {
@@ -174,7 +193,7 @@ template <typename T>
// We've got the lock back here, no matter if we ran wait or not.
// The queue is not empty, so we have something to run. Claim it.
- LinkedRunnable* r = pool->fQueue.tail();
+ LinkedRunnable* r = pool->fQueue.head();
pool->fQueue.remove(r);
« no previous file with comments | « dm/DMTaskRunner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698