| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 #include "webrtc/base/taskrunner.h" | 13 #include "webrtc/base/taskrunner.h" |
| 14 | 14 |
| 15 #include "webrtc/base/common.h" | 15 #include "webrtc/base/common.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | 16 #include "webrtc/base/scoped_ptr.h" |
| 17 #include "webrtc/base/task.h" | 17 #include "webrtc/base/task.h" |
| 18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
| 19 | 19 |
| 20 namespace rtc { | 20 namespace rtc { |
| 21 | 21 |
| 22 TaskRunner::TaskRunner() | 22 TaskRunner::TaskRunner() |
| 23 : TaskParent(this), | 23 : TaskParent(this), |
| 24 next_timeout_task_(NULL), | 24 next_timeout_task_(NULL), |
| 25 tasks_running_(false) | 25 tasks_running_(false) |
| 26 #ifdef _DEBUG | 26 #if !defined(NDEBUG) |
| 27 , abort_count_(0), | 27 , abort_count_(0), |
| 28 deleting_task_(NULL) | 28 deleting_task_(NULL) |
| 29 #endif | 29 #endif |
| 30 { | 30 { |
| 31 } | 31 } |
| 32 | 32 |
| 33 TaskRunner::~TaskRunner() { | 33 TaskRunner::~TaskRunner() { |
| 34 // this kills and deletes children silently! | 34 // this kills and deletes children silently! |
| 35 AbortAllChildren(); | 35 AbortAllChildren(); |
| 36 InternalRunTasks(true); | 36 InternalRunTasks(true); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 bool need_timeout_recalc = false; | 81 bool need_timeout_recalc = false; |
| 82 for (size_t i = 0; i < tasks_.size(); ++i) { | 82 for (size_t i = 0; i < tasks_.size(); ++i) { |
| 83 if (tasks_[i]->IsDone()) { | 83 if (tasks_[i]->IsDone()) { |
| 84 Task* task = tasks_[i]; | 84 Task* task = tasks_[i]; |
| 85 if (next_timeout_task_ && | 85 if (next_timeout_task_ && |
| 86 task->unique_id() == next_timeout_task_->unique_id()) { | 86 task->unique_id() == next_timeout_task_->unique_id()) { |
| 87 next_timeout_task_ = NULL; | 87 next_timeout_task_ = NULL; |
| 88 need_timeout_recalc = true; | 88 need_timeout_recalc = true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 #ifdef _DEBUG | 91 #if !defined(NDEBUG) |
| 92 deleting_task_ = task; | 92 deleting_task_ = task; |
| 93 #endif | 93 #endif |
| 94 delete task; | 94 delete task; |
| 95 #ifdef _DEBUG | 95 #if !defined(NDEBUG) |
| 96 deleting_task_ = NULL; | 96 deleting_task_ = NULL; |
| 97 #endif | 97 #endif |
| 98 tasks_[i] = NULL; | 98 tasks_[i] = NULL; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 // Finally, remove nulls | 101 // Finally, remove nulls |
| 102 std::vector<Task *>::iterator it; | 102 std::vector<Task *>::iterator it; |
| 103 it = std::remove(tasks_.begin(), | 103 it = std::remove(tasks_.begin(), |
| 104 tasks_.end(), | 104 tasks_.end(), |
| 105 reinterpret_cast<Task *>(NULL)); | 105 reinterpret_cast<Task *>(NULL)); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 bool timeout_change = (previous_timeout_time == 0 && next_timeout != 0) || | 215 bool timeout_change = (previous_timeout_time == 0 && next_timeout != 0) || |
| 216 next_timeout < previous_timeout_time || | 216 next_timeout < previous_timeout_time || |
| 217 (previous_timeout_time <= CurrentTime() && | 217 (previous_timeout_time <= CurrentTime() && |
| 218 previous_timeout_time != next_timeout); | 218 previous_timeout_time != next_timeout); |
| 219 if (timeout_change) { | 219 if (timeout_change) { |
| 220 OnTimeoutChange(); | 220 OnTimeoutChange(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace rtc | 224 } // namespace rtc |
| OLD | NEW |