Chromium Code Reviews| Index: base/test/task_runner_test_template.cc |
| =================================================================== |
| --- base/test/task_runner_test_template.cc (revision 178148) |
| +++ 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]; |
|
jar (doing other things)
2013/02/22 23:39:47
aklin: Why do we increment count, when we *don't*
michaeln
2013/02/23 02:38:46
In an effort to speed the process... i'll take a s
akalin
2013/02/26 00:12:23
Yes, this is correct. Perhaps add a comment expla
|
| + ++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::WaitForTasksToComplete(int count) { |
|
jar (doing other things)
2013/02/22 23:39:47
nit: rename, and use >=
|
| + AutoLock lock(lock_); |
| + while (task_runs_ != count) |
| + task_runs_cv_.Wait(); |
| +} |
| + |
| void ExpectRunsTasksOnCurrentThread( |
| bool expected_value, |
| const scoped_refptr<TaskRunner>& task_runner) { |