Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_scheduler/scheduler_worker.h" | 5 #include "base/task_scheduler/scheduler_worker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 outer_ = nullptr; | 71 outer_ = nullptr; |
| 72 DCHECK_EQ(detached_thread.get(), this); | 72 DCHECK_EQ(detached_thread.get(), this); |
| 73 PlatformThread::Detach(thread_handle_); | 73 PlatformThread::Detach(thread_handle_); |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 WaitForWork(); | 77 WaitForWork(); |
| 78 continue; | 78 continue; |
| 79 } | 79 } |
| 80 | 80 |
| 81 std::unique_ptr<Task> task = sequence->TakeTask(); | 81 std::unique_ptr<Task> task = sequence->TakeTask(); |
|
gab
2017/01/05 19:25:46
inline
fdoray
2017/01/05 20:13:37
Done.
| |
| 82 const TaskPriority task_priority = task->traits.priority(); | |
| 83 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; | |
| 84 if (outer_->task_tracker_->RunTask(std::move(task), sequence->token())) | 82 if (outer_->task_tracker_->RunTask(std::move(task), sequence->token())) |
| 85 outer_->delegate_->DidRunTaskWithPriority(task_priority, task_latency); | 83 outer_->delegate_->DidRunTask(); |
| 86 | 84 |
| 87 const bool sequence_became_empty = sequence->Pop(); | 85 const bool sequence_became_empty = sequence->Pop(); |
| 88 | 86 |
| 89 // If |sequence| isn't empty immediately after the pop, re-enqueue it to | 87 // If |sequence| isn't empty immediately after the pop, re-enqueue it to |
| 90 // maintain the invariant that a non-empty Sequence is always referenced | 88 // maintain the invariant that a non-empty Sequence is always referenced |
| 91 // by either a PriorityQueue or a SchedulerWorker. If it is empty | 89 // by either a PriorityQueue or a SchedulerWorker. If it is empty |
| 92 // and there are live references to it, it will be enqueued when a Task is | 90 // and there are live references to it, it will be enqueued when a Task is |
| 93 // added to it. Otherwise, it will be destroyed at the end of this scope. | 91 // added to it. Otherwise, it will be destroyed at the end of this scope. |
| 94 if (!sequence_became_empty) | 92 if (!sequence_became_empty) |
| 95 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); | 93 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 thread_ = Thread::Create(this); | 274 thread_ = Thread::Create(this); |
| 277 } | 275 } |
| 278 | 276 |
| 279 void SchedulerWorker::CreateThreadAssertSynchronized() { | 277 void SchedulerWorker::CreateThreadAssertSynchronized() { |
| 280 thread_lock_.AssertAcquired(); | 278 thread_lock_.AssertAcquired(); |
| 281 CreateThread(); | 279 CreateThread(); |
| 282 } | 280 } |
| 283 | 281 |
| 284 } // namespace internal | 282 } // namespace internal |
| 285 } // namespace base | 283 } // namespace base |
| OLD | NEW |