| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DCHECK_EQ(detached_thread.get(), this); | 63 DCHECK_EQ(detached_thread.get(), this); |
| 64 PlatformThread::Detach(thread_handle_); | 64 PlatformThread::Detach(thread_handle_); |
| 65 outer_ = nullptr; | 65 outer_ = nullptr; |
| 66 break; | 66 break; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 WaitForWork(); | 69 WaitForWork(); |
| 70 continue; | 70 continue; |
| 71 } | 71 } |
| 72 | 72 |
| 73 const Task* task = sequence->PeekTask(); | 73 Task* task = sequence->PeekTask(); |
| 74 const TimeTicks start_time = TimeTicks::Now(); | 74 const TimeTicks start_time = TimeTicks::Now(); |
| 75 if (outer_->task_tracker_->RunTask(task, sequence->token())) | 75 if (outer_->task_tracker_->RunTask(task, sequence->token())) |
| 76 outer_->delegate_->DidRunTask(task, start_time - task->sequenced_time); | 76 outer_->delegate_->DidRunTask(task, start_time - task->sequenced_time); |
| 77 | 77 |
| 78 const bool sequence_became_empty = sequence->PopTask(); | 78 const bool sequence_became_empty = sequence->PopTask(); |
| 79 | 79 |
| 80 // If |sequence| isn't empty immediately after the pop, re-enqueue it to | 80 // If |sequence| isn't empty immediately after the pop, re-enqueue it to |
| 81 // maintain the invariant that a non-empty Sequence is always referenced | 81 // maintain the invariant that a non-empty Sequence is always referenced |
| 82 // by either a PriorityQueue or a SchedulerWorker. If it is empty | 82 // by either a PriorityQueue or a SchedulerWorker. If it is empty |
| 83 // and there are live references to it, it will be enqueued when a Task is | 83 // and there are live references to it, it will be enqueued when a Task is |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 CreateThread(); | 269 CreateThread(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 bool SchedulerWorker::ShouldExitForTesting() const { | 272 bool SchedulerWorker::ShouldExitForTesting() const { |
| 273 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); | 273 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); |
| 274 return should_exit_for_testing_; | 274 return should_exit_for_testing_; |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace internal | 277 } // namespace internal |
| 278 } // namespace base | 278 } // namespace base |
| OLD | NEW |