OLD | NEW |
---|---|
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 Loading... | |
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 bool may_block_ : 1; |
153 bool with_base_sync_primitives_; | 156 bool with_base_sync_primitives_ : 1; |
157 bool priority_set_explicitly_ : 1; | |
gab
2017/04/25 17:16:41
Let's ask Etienne to make sure these bit optimizat
etienneb
2017/04/25 17:45:59
Using
bool x : 1;
bool y : 1;
This will use less
fdoray
2017/04/25 17:57:48
Since there will be very few accesses (ignoring co
etienneb
2017/04/25 18:05:47
If this is not "largely" used, I'll stay with the
fdoray
2017/04/25 18:40:25
Done.
| |
154 TaskPriority priority_; | 158 TaskPriority priority_; |
155 TaskShutdownBehavior shutdown_behavior_; | 159 TaskShutdownBehavior shutdown_behavior_; |
156 }; | 160 }; |
157 | 161 |
158 // Returns string literals for the enums defined in this file. These methods | 162 // Returns string literals for the enums defined in this file. These methods |
159 // should only be used for tracing and debugging. | 163 // should only be used for tracing and debugging. |
160 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority); | 164 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority); |
161 BASE_EXPORT const char* TaskShutdownBehaviorToString( | 165 BASE_EXPORT const char* TaskShutdownBehaviorToString( |
162 TaskShutdownBehavior task_priority); | 166 TaskShutdownBehavior task_priority); |
163 | 167 |
164 // Stream operators so that the enums defined in this file can be used in | 168 // Stream operators so that the enums defined in this file can be used in |
165 // DCHECK and EXPECT statements. | 169 // DCHECK and EXPECT statements. |
166 BASE_EXPORT std::ostream& operator<<(std::ostream& os, | 170 BASE_EXPORT std::ostream& operator<<(std::ostream& os, |
167 const TaskPriority& shutdown_behavior); | 171 const TaskPriority& shutdown_behavior); |
168 BASE_EXPORT std::ostream& operator<<( | 172 BASE_EXPORT std::ostream& operator<<( |
169 std::ostream& os, | 173 std::ostream& os, |
170 const TaskShutdownBehavior& shutdown_behavior); | 174 const TaskShutdownBehavior& shutdown_behavior); |
171 | 175 |
172 } // namespace base | 176 } // namespace base |
173 | 177 |
174 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ | 178 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ |
OLD | NEW |