MCPcopy Create free account
hub / github.com/anyrtcIO-Community/anyRTC-RTMP-OpenSource / UpdateTaskTimeout

Method UpdateTaskTimeout

webrtc/base/taskrunner.cc:151–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149// effectively making the task scheduler O-1 instead of O-N
150
151void TaskRunner::UpdateTaskTimeout(Task* task,
152 int64_t previous_task_timeout_time) {
153 ASSERT(task != NULL);
154 int64_t previous_timeout_time = next_task_timeout();
155 bool task_is_timeout_task = next_timeout_task_ != NULL &&
156 task->unique_id() == next_timeout_task_->unique_id();
157 if (task_is_timeout_task) {
158 previous_timeout_time = previous_task_timeout_time;
159 }
160
161 // if the relevant task has a timeout, then
162 // check to see if it's closer than the current
163 // "about to timeout" task
164 if (task->timeout_time()) {
165 if (next_timeout_task_ == NULL ||
166 (task->timeout_time() <= next_timeout_task_->timeout_time())) {
167 next_timeout_task_ = task;
168 }
169 } else if (task_is_timeout_task) {
170 // otherwise, if the task doesn't have a timeout,
171 // and it used to be our "about to timeout" task,
172 // walk through all the tasks looking for the real
173 // "about to timeout" task
174 RecalcNextTimeout(task);
175 }
176
177 // Note when task_running_, then the running routine
178 // (TaskRunner::InternalRunTasks) is responsible for calling
179 // CheckForTimeoutChange.
180 if (!tasks_running_) {
181 CheckForTimeoutChange(previous_timeout_time);
182 }
183}
184
185void TaskRunner::RecalcNextTimeout(Task *exclude_task) {
186 // walk through all the tasks looking for the one

Callers 2

ResetTimeoutMethod · 0.80
ClearTimeoutMethod · 0.80

Calls 2

unique_idMethod · 0.80
timeout_timeMethod · 0.80

Tested by

no test coverage detected