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