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

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

Issue 2831883003: Do not inherit TaskPriority in TaskTraits. (Closed)
Patch Set: self-review Created 3 years, 8 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 | « base/task_scheduler/post_task.cc ('k') | base/task_scheduler/task_traits.cc » ('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 #ifndef BASE_TASK_SCHEDULER_TASK_TRAITS_H_ 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRAITS_H_
6 #define BASE_TASK_SCHEDULER_TASK_TRAITS_H_ 6 #define BASE_TASK_SCHEDULER_TASK_TRAITS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 // Applies |shutdown_behavior| to tasks with these traits. 136 // Applies |shutdown_behavior| to tasks with these traits.
137 TaskTraits& WithShutdownBehavior(TaskShutdownBehavior shutdown_behavior); 137 TaskTraits& WithShutdownBehavior(TaskShutdownBehavior shutdown_behavior);
138 138
139 // Returns true if tasks with these traits may block. 139 // Returns true if tasks with these traits may block.
140 bool may_block() const { return may_block_; } 140 bool may_block() const { return may_block_; }
141 141
142 // Returns true if tasks with these traits may use base/ sync primitives. 142 // Returns true if tasks with these traits may use base/ sync primitives.
143 bool with_base_sync_primitives() const { return with_base_sync_primitives_; } 143 bool with_base_sync_primitives() const { return with_base_sync_primitives_; }
144 144
145 // Returns true if the priority was set explicitly.
146 bool priority_set_explicitly() const { return priority_set_explicitly_; }
147
145 // Returns the priority of tasks with these traits. 148 // Returns the priority of tasks with these traits.
146 TaskPriority priority() const { return priority_; } 149 TaskPriority priority() const { return priority_; }
147 150
148 // Returns the shutdown behavior of tasks with these traits. 151 // Returns the shutdown behavior of tasks with these traits.
149 TaskShutdownBehavior shutdown_behavior() const { return shutdown_behavior_; } 152 TaskShutdownBehavior shutdown_behavior() const { return shutdown_behavior_; }
150 153
151 private: 154 private:
152 bool may_block_; 155 // Do not rely on defaults hard-coded below beyond the guarantees described on
153 bool with_base_sync_primitives_; 156 // the constructor; anything else is subject to change. Tasks should
154 TaskPriority priority_; 157 // explicitly request defaults if the behavior is critical to the task.
155 TaskShutdownBehavior shutdown_behavior_; 158 bool may_block_ = false;
159 bool with_base_sync_primitives_ = false;
160 bool priority_set_explicitly_ = false;
161 TaskPriority priority_ = TaskPriority::BACKGROUND;
gab 2017/04/25 18:50:42 GetTaskPriorityForCurrentThread() defaults to USER
robliao 2017/04/25 20:06:47 +1
fdoray 2017/04/25 21:20:24 Done.
162 TaskShutdownBehavior shutdown_behavior_ =
163 TaskShutdownBehavior::SKIP_ON_SHUTDOWN;
156 }; 164 };
157 165
158 // Returns string literals for the enums defined in this file. These methods 166 // Returns string literals for the enums defined in this file. These methods
159 // should only be used for tracing and debugging. 167 // should only be used for tracing and debugging.
160 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority); 168 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority);
161 BASE_EXPORT const char* TaskShutdownBehaviorToString( 169 BASE_EXPORT const char* TaskShutdownBehaviorToString(
162 TaskShutdownBehavior task_priority); 170 TaskShutdownBehavior task_priority);
163 171
164 // Stream operators so that the enums defined in this file can be used in 172 // Stream operators so that the enums defined in this file can be used in
165 // DCHECK and EXPECT statements. 173 // DCHECK and EXPECT statements.
166 BASE_EXPORT std::ostream& operator<<(std::ostream& os, 174 BASE_EXPORT std::ostream& operator<<(std::ostream& os,
167 const TaskPriority& shutdown_behavior); 175 const TaskPriority& shutdown_behavior);
168 BASE_EXPORT std::ostream& operator<<( 176 BASE_EXPORT std::ostream& operator<<(
169 std::ostream& os, 177 std::ostream& os,
170 const TaskShutdownBehavior& shutdown_behavior); 178 const TaskShutdownBehavior& shutdown_behavior);
171 179
172 } // namespace base 180 } // namespace base
173 181
174 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ 182 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/post_task.cc ('k') | base/task_scheduler/task_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698