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 #include "base/task_scheduler/task_traits.h" | 5 #include "base/task_scheduler/task_traits.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <ostream> | 9 #include <ostream> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/task_scheduler/scoped_set_task_priority_for_current_thread.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 | 15 |
15 // Do not rely on defaults hard-coded below beyond the guarantees described in | 16 // Do not rely on defaults hard-coded below beyond the guarantees described in |
16 // the header; anything else is subject to change. Tasks should explicitly | 17 // the header; anything else is subject to change. Tasks should explicitly |
17 // request defaults if the behavior is critical to the task. | 18 // request defaults if the behavior is critical to the task. |
18 TaskTraits::TaskTraits() | 19 TaskTraits::TaskTraits() |
19 : with_file_io_(false), | 20 : with_file_io_(false), |
20 with_wait_(false), | 21 with_wait_(false), |
21 priority_(TaskPriority::BACKGROUND), | 22 priority_(internal::GetTaskPriorityForCurrentThread()), |
22 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} | 23 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} |
23 | 24 |
24 TaskTraits::~TaskTraits() = default; | 25 TaskTraits::~TaskTraits() = default; |
25 | 26 |
26 TaskTraits& TaskTraits::WithFileIO() { | 27 TaskTraits& TaskTraits::WithFileIO() { |
27 with_file_io_ = true; | 28 with_file_io_ = true; |
28 return *this; | 29 return *this; |
29 } | 30 } |
30 | 31 |
31 TaskTraits& TaskTraits::WithWait() { | 32 TaskTraits& TaskTraits::WithWait() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return os; | 77 return os; |
77 } | 78 } |
78 | 79 |
79 std::ostream& operator<<(std::ostream& os, | 80 std::ostream& operator<<(std::ostream& os, |
80 const TaskShutdownBehavior& shutdown_behavior) { | 81 const TaskShutdownBehavior& shutdown_behavior) { |
81 os << TaskShutdownBehaviorToString(shutdown_behavior); | 82 os << TaskShutdownBehaviorToString(shutdown_behavior); |
82 return os; | 83 return os; |
83 } | 84 } |
84 | 85 |
85 } // namespace base | 86 } // namespace base |
OLD | NEW |