| 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/task_scheduler_impl.h" | 5 #include "base/task_scheduler/task_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const size_t index = worker_pool_index_for_traits_callback_.Run(traits); | 111 const size_t index = worker_pool_index_for_traits_callback_.Run(traits); |
| 112 DCHECK_LT(index, worker_pools_.size()); | 112 DCHECK_LT(index, worker_pools_.size()); |
| 113 return worker_pools_[index].get(); | 113 return worker_pools_[index].get(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void TaskSchedulerImpl::ReEnqueueSequenceCallback( | 116 void TaskSchedulerImpl::ReEnqueueSequenceCallback( |
| 117 scoped_refptr<Sequence> sequence) { | 117 scoped_refptr<Sequence> sequence) { |
| 118 DCHECK(sequence); | 118 DCHECK(sequence); |
| 119 | 119 |
| 120 const SequenceSortKey sort_key = sequence->GetSortKey(); | 120 const SequenceSortKey sort_key = sequence->GetSortKey(); |
| 121 TaskTraits traits(sequence->PeekTask()->traits); | |
| 122 | 121 |
| 123 // Update the priority of |traits| so that the next task in |sequence| runs | 122 // The next task in |sequence| should run in a worker pool suited for its |
| 124 // with the highest priority in |sequence| as opposed to the next task's | 123 // traits, except for the priority which is adjusted to the highest priority |
| 125 // specific priority. | 124 // in |sequence|. |
| 126 traits.WithPriority(sort_key.priority()); | 125 const TaskTraits traits = |
| 126 sequence->PeekTaskTraits().WithPriority(sort_key.priority()); |
| 127 | 127 |
| 128 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), | 128 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), |
| 129 sort_key); | 129 sort_key); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() { | 132 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() { |
| 133 service_thread_->WakeUp(); | 133 service_thread_->WakeUp(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace internal | 136 } // namespace internal |
| 137 } // namespace base | 137 } // namespace base |
| OLD | NEW |