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

Unified Diff: base/threading/sequenced_worker_pool.cc

Issue 11649032: Flush SequenceWorkerPool tasks after each unit test. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years 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 | « no previous file | content/browser/browser_thread_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | content/browser/browser_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698