Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: base/task_scheduler/scheduler_worker.cc

Issue 2019763002: TaskScheduler: Atomic operations in TaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR danakj #51 (add memory barriers) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 // PlatformThread::Delegate. 29 // PlatformThread::Delegate.
30 void ThreadMain() override { 30 void ThreadMain() override {
31 // Set if this thread was detached. 31 // Set if this thread was detached.
32 std::unique_ptr<Thread> detached_thread; 32 std::unique_ptr<Thread> detached_thread;
33 33
34 outer_->delegate_->OnMainEntry(outer_); 34 outer_->delegate_->OnMainEntry(outer_);
35 35
36 // A SchedulerWorker starts out waiting for work. 36 // A SchedulerWorker starts out waiting for work.
37 WaitForWork(); 37 WaitForWork();
38 38
39 while (!outer_->task_tracker_->shutdown_completed() && 39 while (!outer_->task_tracker_->IsShutdownComplete() &&
40 !outer_->ShouldExitForTesting()) { 40 !outer_->ShouldExitForTesting()) {
41 DCHECK(outer_); 41 DCHECK(outer_);
42 // Get the sequence containing the next task to execute. 42 // Get the sequence containing the next task to execute.
43 scoped_refptr<Sequence> sequence = outer_->delegate_->GetWork(outer_); 43 scoped_refptr<Sequence> sequence = outer_->delegate_->GetWork(outer_);
44 if (!sequence) { 44 if (!sequence) {
45 if (outer_->delegate_->CanDetach(outer_)) { 45 if (outer_->delegate_->CanDetach(outer_)) {
46 detached_thread = outer_->Detach(); 46 detached_thread = outer_->Detach();
47 if (detached_thread) { 47 if (detached_thread) {
48 DCHECK_EQ(detached_thread.get(), this); 48 DCHECK_EQ(detached_thread.get(), this);
49 PlatformThread::Detach(thread_handle_); 49 PlatformThread::Detach(thread_handle_);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 CreateThread(); 213 CreateThread();
214 } 214 }
215 215
216 bool SchedulerWorker::ShouldExitForTesting() const { 216 bool SchedulerWorker::ShouldExitForTesting() const {
217 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); 217 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_);
218 return should_exit_for_testing_; 218 return should_exit_for_testing_;
219 } 219 }
220 220
221 } // namespace internal 221 } // namespace internal
222 } // namespace base 222 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698