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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Returns the shutdown behavior of tasks with these traits. | 107 // Returns the shutdown behavior of tasks with these traits. |
108 TaskShutdownBehavior shutdown_behavior() const { return shutdown_behavior_; } | 108 TaskShutdownBehavior shutdown_behavior() const { return shutdown_behavior_; } |
109 | 109 |
110 private: | 110 private: |
111 bool with_file_io_; | 111 bool with_file_io_; |
112 TaskPriority priority_; | 112 TaskPriority priority_; |
113 TaskShutdownBehavior shutdown_behavior_; | 113 TaskShutdownBehavior shutdown_behavior_; |
114 }; | 114 }; |
115 | 115 |
116 // Describes how tasks are executed by a task runner. | |
117 enum class ExecutionMode { | |
118 // Can execute multiple tasks at a time in any order. | |
119 PARALLEL, | |
120 | |
121 // Executes one task at a time in posting order. The sequence’s priority is | |
122 // equivalent to the highest priority pending task in the sequence. | |
123 SEQUENCED, | |
124 | |
125 // Executes one task at a time on a single thread in posting order. | |
126 SINGLE_THREADED, | |
127 }; | |
128 | |
129 // Returns string literals for the enums defined in this file. These methods | 116 // Returns string literals for the enums defined in this file. These methods |
130 // should only be used for tracing and debugging. | 117 // should only be used for tracing and debugging. |
131 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority); | 118 BASE_EXPORT const char* TaskPriorityToString(TaskPriority task_priority); |
132 BASE_EXPORT const char* TaskShutdownBehaviorToString( | 119 BASE_EXPORT const char* TaskShutdownBehaviorToString( |
133 TaskShutdownBehavior task_priority); | 120 TaskShutdownBehavior task_priority); |
134 BASE_EXPORT const char* ExecutionModeToString(ExecutionMode task_priority); | |
135 | 121 |
136 // Stream operators so that the enums defined in this file can be used in | 122 // Stream operators so that the enums defined in this file can be used in |
137 // DCHECK and EXPECT statements. | 123 // DCHECK and EXPECT statements. |
138 BASE_EXPORT std::ostream& operator<<(std::ostream& os, | 124 BASE_EXPORT std::ostream& operator<<(std::ostream& os, |
139 const TaskPriority& shutdown_behavior); | 125 const TaskPriority& shutdown_behavior); |
140 BASE_EXPORT std::ostream& operator<<( | 126 BASE_EXPORT std::ostream& operator<<( |
141 std::ostream& os, | 127 std::ostream& os, |
142 const TaskShutdownBehavior& shutdown_behavior); | 128 const TaskShutdownBehavior& shutdown_behavior); |
143 BASE_EXPORT std::ostream& operator<<(std::ostream& os, | |
144 const ExecutionMode& execution_mode); | |
145 | 129 |
146 } // namespace base | 130 } // namespace base |
147 | 131 |
148 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ | 132 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ |
OLD | NEW |