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

Unified Diff: base/test/task_runner_test_template.cc

Issue 11649032: Flush SequenceWorkerPool tasks after each unit test. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | « base/test/task_runner_test_template.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/task_runner_test_template.cc
===================================================================
--- base/test/task_runner_test_template.cc (revision 186525)
+++ base/test/task_runner_test_template.cc (working copy)
@@ -8,7 +8,7 @@
namespace internal {
-TaskTracker::TaskTracker() {}
+TaskTracker::TaskTracker() : task_runs_(0), task_runs_cv_(&lock_) {}
TaskTracker::~TaskTracker() {}
@@ -17,18 +17,26 @@
}
void TaskTracker::RunTask(const Closure& task, int i) {
- AutoLock lock(task_run_counts_lock_);
+ AutoLock lock(lock_);
if (!task.is_null()) {
task.Run();
}
++task_run_counts_[i];
+ ++task_runs_;
+ task_runs_cv_.Signal();
}
std::map<int, int> TaskTracker::GetTaskRunCounts() const {
- AutoLock lock(task_run_counts_lock_);
+ AutoLock lock(lock_);
return task_run_counts_;
}
+void TaskTracker::WaitForCompletedTasks(int count) {
+ AutoLock lock(lock_);
+ while (task_runs_ < count)
+ task_runs_cv_.Wait();
+}
+
void ExpectRunsTasksOnCurrentThread(
bool expected_value,
const scoped_refptr<TaskRunner>& task_runner) {
« no previous file with comments | « base/test/task_runner_test_template.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698