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

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

Issue 2698843006: Introduce SchedulerSingleThreadTaskRunnerManager (Closed)
Patch Set: Merge in https://codereview.chromium.org/2726073002/ Created 3 years, 9 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 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_
6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // When true is returned: 78 // When true is returned:
79 // - The next WakeUp() could be more costly due to new thread creation. 79 // - The next WakeUp() could be more costly due to new thread creation.
80 // - The worker will take this as a signal that it can detach, but it is not 80 // - The worker will take this as a signal that it can detach, but it is not
81 // obligated to do so. 81 // obligated to do so.
82 virtual bool CanDetach(SchedulerWorker* worker) = 0; 82 virtual bool CanDetach(SchedulerWorker* worker) = 0;
83 83
84 // Called by a thread before it detaches. This method is not allowed to 84 // Called by a thread before it detaches. This method is not allowed to
85 // acquire a SchedulerLock because it is called within the scope of another 85 // acquire a SchedulerLock because it is called within the scope of another
86 // SchedulerLock. 86 // SchedulerLock.
87 virtual void OnDetach() = 0; 87 virtual void OnDetach() = 0;
88
89 // Called by a thread right before the main function exits.
90 virtual void OnMainExit() {}
88 }; 91 };
89 92
90 enum class InitialState { ALIVE, DETACHED }; 93 enum class InitialState { ALIVE, DETACHED };
91 94
92 // Creates a SchedulerWorker that runs Tasks from Sequences returned by 95 // Creates a SchedulerWorker that runs Tasks from Sequences returned by
93 // |delegate|. |priority_hint| is the preferred thread priority; the actual 96 // |delegate|. |priority_hint| is the preferred thread priority; the actual
94 // thread priority depends on shutdown state and platform capabilities. 97 // thread priority depends on shutdown state and platform capabilities.
95 // |task_tracker| is used to handle shutdown behavior of Tasks. If 98 // |task_tracker| is used to handle shutdown behavior of Tasks. If
96 // |worker_state| is DETACHED, the thread will be created upon a WakeUp(). 99 // |worker_state| is DETACHED, the thread will be created upon a WakeUp().
97 // Returns nullptr if creating the underlying platform thread fails during 100 // Returns nullptr if creating the underlying platform thread fails during
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Set once JoinForTesting() has been called. 192 // Set once JoinForTesting() has been called.
190 AtomicFlag join_called_for_testing_; 193 AtomicFlag join_called_for_testing_;
191 194
192 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); 195 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker);
193 }; 196 };
194 197
195 } // namespace internal 198 } // namespace internal
196 } // namespace base 199 } // namespace base
197 200
198 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ 201 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc ('k') | base/task_scheduler/scheduler_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698