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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DCHECK_EQ(detached_thread.get(), this); | 62 DCHECK_EQ(detached_thread.get(), this); |
63 PlatformThread::Detach(thread_handle_); | 63 PlatformThread::Detach(thread_handle_); |
64 outer_ = nullptr; | 64 outer_ = nullptr; |
65 break; | 65 break; |
66 } | 66 } |
67 } | 67 } |
68 WaitForWork(); | 68 WaitForWork(); |
69 continue; | 69 continue; |
70 } | 70 } |
71 | 71 |
72 outer_->task_tracker_->RunTask(sequence->PeekTask()); | 72 outer_->task_tracker_->RunNextTaskInSequence(sequence.get()); |
73 | 73 |
74 const bool sequence_became_empty = sequence->PopTask(); | 74 const bool sequence_became_empty = sequence->PopTask(); |
75 | 75 |
76 // If |sequence| isn't empty immediately after the pop, re-enqueue it to | 76 // If |sequence| isn't empty immediately after the pop, re-enqueue it to |
77 // maintain the invariant that a non-empty Sequence is always referenced | 77 // maintain the invariant that a non-empty Sequence is always referenced |
78 // by either a PriorityQueue or a SchedulerWorker. If it is empty | 78 // by either a PriorityQueue or a SchedulerWorker. If it is empty |
79 // and there are live references to it, it will be enqueued when a Task is | 79 // and there are live references to it, it will be enqueued when a Task is |
80 // added to it. Otherwise, it will be destroyed at the end of this scope. | 80 // added to it. Otherwise, it will be destroyed at the end of this scope. |
81 if (!sequence_became_empty) | 81 if (!sequence_became_empty) |
82 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); | 82 outer_->delegate_->ReEnqueueSequence(std::move(sequence)); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 CreateThread(); | 256 CreateThread(); |
257 } | 257 } |
258 | 258 |
259 bool SchedulerWorker::ShouldExitForTesting() const { | 259 bool SchedulerWorker::ShouldExitForTesting() const { |
260 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); | 260 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); |
261 return should_exit_for_testing_; | 261 return should_exit_for_testing_; |
262 } | 262 } |
263 | 263 |
264 } // namespace internal | 264 } // namespace internal |
265 } // namespace base | 265 } // namespace base |
OLD | NEW |