OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/test_simple_task_runner.h" | 5 #include "base/test/test_simple_task_runner.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void TestSimpleTaskRunner::RunPendingTasks() { | 71 void TestSimpleTaskRunner::RunPendingTasks() { |
72 DCHECK(RunsTasksOnCurrentThread()); | 72 DCHECK(RunsTasksOnCurrentThread()); |
73 | 73 |
74 // Swap with a local variable to avoid re-entrancy problems. | 74 // Swap with a local variable to avoid re-entrancy problems. |
75 std::deque<TestPendingTask> tasks_to_run; | 75 std::deque<TestPendingTask> tasks_to_run; |
76 { | 76 { |
77 AutoLock auto_lock(lock_); | 77 AutoLock auto_lock(lock_); |
78 tasks_to_run.swap(pending_tasks_); | 78 tasks_to_run.swap(pending_tasks_); |
79 } | 79 } |
80 | 80 |
81 for (const auto& task : tasks_to_run) | 81 for (auto& task : tasks_to_run) |
82 task.task.Run(); | 82 std::move(task.task).Run(); |
83 } | 83 } |
84 | 84 |
85 void TestSimpleTaskRunner::RunUntilIdle() { | 85 void TestSimpleTaskRunner::RunUntilIdle() { |
86 while (!pending_tasks_.empty()) { | 86 while (!pending_tasks_.empty()) { |
87 RunPendingTasks(); | 87 RunPendingTasks(); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 } // namespace base | 91 } // namespace base |
OLD | NEW |