Index: base/threading/sequenced_worker_pool.cc |
=================================================================== |
--- base/threading/sequenced_worker_pool.cc (revision 174239) |
+++ base/threading/sequenced_worker_pool.cc (working copy) |
@@ -389,7 +389,7 @@ |
ConditionVariable has_work_cv_; |
// Condition variable that is waited on by non-worker threads (in |
- // FlushForTesting()) until IsIdle() goes to true. |
+ // FlushForTesting()) until IsIdle() goes to true or Shutdown completes. |
michaeln
2012/12/21 03:17:55
I might be able to better normalize things by intr
|
ConditionVariable is_idle_cv_; |
// Condition variable that is waited on by non-worker threads (in |
@@ -610,8 +610,9 @@ |
} |
void SequencedWorkerPool::Inner::FlushForTesting() { |
+ base::ThreadRestrictions::ScopedAllowWait allow_wait; |
AutoLock lock(lock_); |
- while (!IsIdle()) |
+ while (!IsIdle() && !shutdown_called_) |
is_idle_cv_.Wait(); |
} |
@@ -635,8 +636,10 @@ |
SignalHasWork(); |
// There are no pending or running tasks blocking shutdown, we're done. |
- if (CanShutdown()) |
+ if (CanShutdown()) { |
+ is_idle_cv_.Signal(); |
michaeln
2012/12/21 02:50:47
FlushForTesting can wait forever if Shutdown happe
|
return; |
+ } |
} |
// If we're here, then something is blocking shutdown. So wait for |
@@ -652,6 +655,7 @@ |
AutoLock lock(lock_); |
while (!CanShutdown()) |
can_shutdown_cv_.Wait(); |
+ is_idle_cv_.Signal(); |
} |
UMA_HISTOGRAM_TIMES("SequencedWorkerPool.ShutdownDelayTime", |
TimeTicks::Now() - shutdown_wait_begin); |