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); |