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

Unified Diff: src/utils/SkThreadPool.cpp

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/utils/SkThreadPool.h ('k') | tests/OnceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkThreadPool.cpp
diff --git a/src/utils/SkThreadPool.cpp b/src/utils/SkThreadPool.cpp
index 3d19d1c5b9f8a75dde1ab574f98fe6f7b61fd3eb..e078af3ba3e914add1428460b66c24f6dafe9bb6 100644
--- a/src/utils/SkThreadPool.cpp
+++ b/src/utils/SkThreadPool.cpp
@@ -39,6 +39,12 @@ SkThreadPool::SkThreadPool(int count)
}
SkThreadPool::~SkThreadPool() {
+ if (!fDone) {
+ this->wait();
+ }
+}
+
+void SkThreadPool::wait() {
fReady.lock();
fDone = true;
fReady.broadcast();
@@ -99,6 +105,7 @@ void SkThreadPool::add(SkRunnable* r) {
// We have some threads. Queue it up!
fReady.lock();
+ SkASSERT(!fDone); // We shouldn't be adding work to a pool that's shut down.
LinkedRunnable* linkedRunnable = SkNEW(LinkedRunnable);
linkedRunnable->fRunnable = r;
fQueue.addToHead(linkedRunnable);
« no previous file with comments | « include/utils/SkThreadPool.h ('k') | tests/OnceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698