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

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

Issue 2019763002: TaskScheduler: Atomic operations in TaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab #26 Created 4 years, 6 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') | base/task_scheduler/task_tracker.cc » ('J')
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_thread.h" 5 #include "base/task_scheduler/scheduler_worker_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, 58 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_,
59 thread_priority); 59 thread_priority);
60 } 60 }
61 61
62 void SchedulerWorkerThread::ThreadMain() { 62 void SchedulerWorkerThread::ThreadMain() {
63 delegate_->OnMainEntry(this); 63 delegate_->OnMainEntry(this);
64 64
65 // A SchedulerWorkerThread starts out sleeping. 65 // A SchedulerWorkerThread starts out sleeping.
66 wake_up_event_.Wait(); 66 wake_up_event_.Wait();
67 67
68 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) { 68 while (!task_tracker_->ShutdownCompleted() && !ShouldExitForTesting()) {
69 // Get the sequence containing the next task to execute. 69 // Get the sequence containing the next task to execute.
70 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); 70 scoped_refptr<Sequence> sequence = delegate_->GetWork(this);
71 71
72 if (!sequence) { 72 if (!sequence) {
73 TimeDelta sleep_time = delegate_->GetSleepTimeout(); 73 TimeDelta sleep_time = delegate_->GetSleepTimeout();
74 if (sleep_time.is_max()) { 74 if (sleep_time.is_max()) {
75 // Calling TimedWait with TimeDelta::Max is not recommended per 75 // Calling TimedWait with TimeDelta::Max is not recommended per
76 // http://crbug.com/465948. 76 // http://crbug.com/465948.
77 wake_up_event_.Wait(); 77 wake_up_event_.Wait();
78 } else { 78 } else {
(...skipping 23 matching lines...) Expand all
102 } 102 }
103 } 103 }
104 104
105 bool SchedulerWorkerThread::ShouldExitForTesting() const { 105 bool SchedulerWorkerThread::ShouldExitForTesting() const {
106 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); 106 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_);
107 return should_exit_for_testing_; 107 return should_exit_for_testing_;
108 } 108 }
109 109
110 } // namespace internal 110 } // namespace internal
111 } // namespace base 111 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | base/task_scheduler/task_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698