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

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

Issue 1876363004: TaskScheduler [11] Support ExecutionMode::SINGLE_THREADED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@8_delayed
Patch Set: add #include <algorithm> Created 4 years, 7 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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 task_tracker_(task_tracker) { 52 task_tracker_(task_tracker) {
53 DCHECK(delegate_); 53 DCHECK(delegate_);
54 DCHECK(task_tracker_); 54 DCHECK(task_tracker_);
55 55
56 const size_t kDefaultStackSize = 0; 56 const size_t kDefaultStackSize = 0;
57 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, 57 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_,
58 thread_priority); 58 thread_priority);
59 } 59 }
60 60
61 void SchedulerWorkerThread::ThreadMain() { 61 void SchedulerWorkerThread::ThreadMain() {
62 delegate_->OnMainEntry(); 62 delegate_->OnMainEntry(this);
63 63
64 // A SchedulerWorkerThread starts out sleeping. 64 // A SchedulerWorkerThread starts out sleeping.
65 wake_up_event_.Wait(); 65 wake_up_event_.Wait();
66 66
67 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) { 67 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) {
68 // Get the sequence containing the next task to execute. 68 // Get the sequence containing the next task to execute.
69 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); 69 scoped_refptr<Sequence> sequence = delegate_->GetWork(this);
70 70
71 if (!sequence) { 71 if (!sequence) {
72 wake_up_event_.Wait(); 72 wake_up_event_.Wait();
(...skipping 21 matching lines...) Expand all
94 } 94 }
95 } 95 }
96 96
97 bool SchedulerWorkerThread::ShouldExitForTesting() const { 97 bool SchedulerWorkerThread::ShouldExitForTesting() const {
98 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); 98 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_);
99 return should_exit_for_testing_; 99 return should_exit_for_testing_;
100 } 100 }
101 101
102 } // namespace internal 102 } // namespace internal
103 } // namespace base 103 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_thread.h ('k') | base/task_scheduler/scheduler_worker_thread_stack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698