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

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

Issue 1705253002: TaskScheduler [3/9] Task and Sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_1_scheduler_lock
Patch Set: self review Created 4 years, 10 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_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.
gab 2016/02/18 20:22:34 Append something like this to the comment : "Note:
fdoray 2016/02/18 20:52:04 Done.
16 enum class TaskPriority : TaskPriorityUnderlyingType { 22 enum class TaskPriority : internal::TaskPriorityUnderlyingType {
17 // This task affects UI immediately after a user interaction. 23 // User won't notice if this task takes an arbitrarily long time to complete.
18 // Example: Generating data shown in the UI immediately after a click. 24 BACKGROUND = 0,
19 USER_BLOCKING = 2,
20 // This task affects UI or responsiveness of future user interactions. It is 25 // This task affects UI or responsiveness of future user interactions. It is
21 // not an immediate response to a user interaction. 26 // not an immediate response to a user interaction.
22 // Examples: 27 // Examples:
23 // - Updating the UI to reflect progress on a long task. 28 // - Updating the UI to reflect progress on a long task.
24 // - Loading data that might be shown in the UI after a future user 29 // - Loading data that might be shown in the UI after a future user
25 // interaction. 30 // interaction.
26 USER_VISIBLE = 1, 31 USER_VISIBLE,
27 // Everything else (user won't notice if this takes an arbitrarily long time 32 // This task affects UI immediately after a user interaction.
28 // to complete). 33 // Example: Generating data shown in the UI immediately after a click.
29 BACKGROUND = 0, 34 USER_BLOCKING,
35 // This will always be equal to the highest priority available.
36 HIGHEST = USER_BLOCKING,
30 }; 37 };
31 38
32 const TaskPriorityUnderlyingType kNumTaskPriorities = 3;
33
34 // Valid shutdown behaviors supported by the task scheduler. 39 // Valid shutdown behaviors supported by the task scheduler.
35 enum class TaskShutdownBehavior { 40 enum class TaskShutdownBehavior {
36 // Tasks posted with this mode which have not started executing before 41 // Tasks posted with this mode which have not started executing before
37 // shutdown is initiated will never run. Tasks with this mode running at 42 // shutdown is initiated will never run. Tasks with this mode running at
38 // shutdown will be ignored (the worker thread will not be joined). 43 // shutdown will be ignored (the worker thread will not be joined).
39 // 44 //
40 // This option provides a nice way to post stuff you don't want blocking 45 // 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 46 // 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 47 // blocked on the OS, you may not want to stop shutdown, since the result
43 // doesn't really matter at that point. 48 // doesn't really matter at that point.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 PARALLEL, 115 PARALLEL,
111 116
112 // Executes one task at a time in posting order. The sequence’s priority is 117 // 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. 118 // equivalent to the highest priority pending task in the sequence.
114 SEQUENCED, 119 SEQUENCED,
115 120
116 // Executes one task at a time on a single thread in posting order. 121 // Executes one task at a time on a single thread in posting order.
117 SINGLE_THREADED, 122 SINGLE_THREADED,
118 }; 123 };
119 124
125 // Pretty Printer for Google Test.
126 void BASE_EXPORT PrintTo(const TaskPriority& task_priority, std::ostream* os);
127
120 } // namespace base 128 } // namespace base
121 129
122 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_ 130 #endif // BASE_TASK_SCHEDULER_TASK_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698