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 if (outer_->task_tracker_->RunTask(sequence->TakeTask(), |
82 const TaskPriority task_priority = task->traits.priority(); | 82 sequence->token())) { |
83 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; | 83 outer_->delegate_->DidRunTask(); |
84 if (outer_->task_tracker_->RunTask(std::move(task), sequence->token())) | 84 } |
85 outer_->delegate_->DidRunTaskWithPriority(task_priority, task_latency); | |
86 | 85 |
87 const bool sequence_became_empty = sequence->Pop(); | 86 const bool sequence_became_empty = sequence->Pop(); |
88 | 87 |
89 // If |sequence| isn't empty immediately after the pop, re-enqueue it to | 88 // 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 | 89 // maintain the invariant that a non-empty Sequence is always referenced |
91 // by either a PriorityQueue or a SchedulerWorker. If it is empty | 90 // 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 | 91 // 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. | 92 // added to it. Otherwise, it will be destroyed at the end of this scope. |
94 if (!sequence_became_empty) | 93 if (!sequence_became_empty) |
95 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); | 94 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 thread_ = Thread::Create(this); | 275 thread_ = Thread::Create(this); |
277 } | 276 } |
278 | 277 |
279 void SchedulerWorker::CreateThreadAssertSynchronized() { | 278 void SchedulerWorker::CreateThreadAssertSynchronized() { |
280 thread_lock_.AssertAcquired(); | 279 thread_lock_.AssertAcquired(); |
281 CreateThread(); | 280 CreateThread(); |
282 } | 281 } |
283 | 282 |
284 } // namespace internal | 283 } // namespace internal |
285 } // namespace base | 284 } // namespace base |
OLD | NEW |