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> | |
9 | |
10 #include <iosfwd> | |
11 | |
8 #include "base/base_export.h" | 12 #include "base/base_export.h" |
9 #include "build/build_config.h" | 13 #include "build/build_config.h" |
10 | 14 |
11 namespace base { | 15 namespace base { |
12 | 16 |
13 using TaskPriorityUnderlyingType = char; | 17 namespace internal { |
18 using TaskPriorityUnderlyingType = uint8_t; | |
19 } // namespace internal | |
14 | 20 |
15 // Valid priorities supported by the task scheduler. | 21 // Valid priorities supported by the task scheduler. Note: internal algorithms |
16 enum class TaskPriority : TaskPriorityUnderlyingType { | 22 // depend on priorities being expressed as a continuous zero-based list from |
17 // This task affects UI immediately after a user interaction. | 23 // lowest to highest priority. Users of this API shouldn't otherwise care about |
18 // Example: Generating data shown in the UI immediately after a click. | 24 // nor use the underlying values. |
19 USER_BLOCKING = 2, | 25 enum class TaskPriority : internal::TaskPriorityUnderlyingType { |
26 // This will always be equal to the lowest priority available. | |
27 LOWEST = 0, | |
28 // User won't notice if this task takes an arbitrarily long time to complete. | |
29 BACKGROUND = LOWEST, | |
20 // This task affects UI or responsiveness of future user interactions. It is | 30 // This task affects UI or responsiveness of future user interactions. It is |
21 // not an immediate response to a user interaction. | 31 // not an immediate response to a user interaction. |
22 // Examples: | 32 // Examples: |
23 // - Updating the UI to reflect progress on a long task. | 33 // - Updating the UI to reflect progress on a long task. |
24 // - Loading data that might be shown in the UI after a future user | 34 // - Loading data that might be shown in the UI after a future user |
25 // interaction. | 35 // interaction. |
26 USER_VISIBLE = 1, | 36 USER_VISIBLE, |
27 // Everything else (user won't notice if this takes an arbitrarily long time | 37 // This task affects UI immediately after a user interaction. |
28 // to complete). | 38 // Example: Generating data shown in the UI immediately after a click. |
29 BACKGROUND = 0, | 39 USER_BLOCKING, |
40 // This will always be equal to the highest priority available. | |
41 HIGHEST = USER_BLOCKING, | |
30 }; | 42 }; |
31 | 43 |
32 const TaskPriorityUnderlyingType kNumTaskPriorities = 3; | |
33 | |
34 // Valid shutdown behaviors supported by the task scheduler. | 44 // Valid shutdown behaviors supported by the task scheduler. |
35 enum class TaskShutdownBehavior { | 45 enum class TaskShutdownBehavior { |
36 // Tasks posted with this mode which have not started executing before | 46 // Tasks posted with this mode which have not started executing before |
37 // shutdown is initiated will never run. Tasks with this mode running at | 47 // shutdown is initiated will never run. Tasks with this mode running at |
38 // shutdown will be ignored (the worker thread will not be joined). | 48 // shutdown will be ignored (the worker thread will not be joined). |
39 // | 49 // |
40 // This option provides a nice way to post stuff you don't want blocking | 50 // This option provides a nice way to post stuff you don't want blocking |
41 // shutdown. For example, you might be doing a slow DNS lookup and if it's | 51 // shutdown. For example, you might be doing a slow DNS lookup and if it's |
42 // blocked on the OS, you may not want to stop shutdown, since the result | 52 // blocked on the OS, you may not want to stop shutdown, since the result |
43 // doesn't really matter at that point. | 53 // doesn't really matter at that point. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 PARALLEL, | 120 PARALLEL, |
111 | 121 |
112 // Executes one task at a time in posting order. The sequence’s priority is | 122 // Executes one task at a time in posting order. The sequence’s priority is |
113 // equivalent to the highest priority pending task in the sequence. | 123 // equivalent to the highest priority pending task in the sequence. |
114 SEQUENCED, | 124 SEQUENCED, |
115 | 125 |
116 // Executes one task at a time on a single thread in posting order. | 126 // Executes one task at a time on a single thread in posting order. |
117 SINGLE_THREADED, | 127 SINGLE_THREADED, |
118 }; | 128 }; |
119 | 129 |
130 // Pretty Printer for Google Test. | |
131 void BASE_EXPORT PrintTo(const TaskPriority& task_priority, std::ostream* os); | |
robliao
2016/02/19 02:33:43
Can this go in a test only utils file?
https://cod
fdoray
2016/02/19 14:12:15
It was in a test only file, but gab asked me to mo
gab
2016/02/19 16:50:47
Keep it here is my vote. string16 does it, it won'
fdoray
2016/02/19 22:28:29
ok, keeping the declaration here.
| |
132 | |
120 } // namespace base | 133 } // namespace base |
121 | 134 |
122 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ | 135 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ |
OLD | NEW |