OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/task_queue.h" | 5 #include <stdbool.h> |
| 6 #include <deque> |
6 | 7 |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/task.h" |
| 11 #include "base/task_queue.h" |
9 | 12 |
10 TaskQueue::TaskQueue() { | 13 TaskQueue::TaskQueue() { |
11 } | 14 } |
12 | 15 |
13 TaskQueue::~TaskQueue() { | 16 TaskQueue::~TaskQueue() { |
14 // We own all the pointes in |queue_|. It is our job to delete them. | 17 // We own all the pointes in |queue_|. It is our job to delete them. |
15 STLDeleteElements(&queue_); | 18 STLDeleteElements(&queue_); |
16 } | 19 } |
17 | 20 |
18 void TaskQueue::Push(Task* task) { | 21 void TaskQueue::Push(Task* task) { |
(...skipping 21 matching lines...) Expand all Loading... |
40 queue_.swap(ready); | 43 queue_.swap(ready); |
41 | 44 |
42 // Run the tasks that are ready. | 45 // Run the tasks that are ready. |
43 std::deque<Task*>::const_iterator task; | 46 std::deque<Task*>::const_iterator task; |
44 for (task = ready.begin(); task != ready.end(); ++task) { | 47 for (task = ready.begin(); task != ready.end(); ++task) { |
45 // Run the task and then delete it. | 48 // Run the task and then delete it. |
46 (*task)->Run(); | 49 (*task)->Run(); |
47 delete (*task); | 50 delete (*task); |
48 } | 51 } |
49 } | 52 } |
OLD | NEW |