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

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

Issue 2541353003: TaskScheduler: Initialize TaskTraits with the priority of the current thread. (Closed)
Patch Set: improve comment Created 4 years 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
« no previous file with comments | « base/task_scheduler/task_traits.h ('k') | base/task_scheduler/task_traits_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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
OLDNEW
« no previous file with comments | « base/task_scheduler/task_traits.h ('k') | base/task_scheduler/task_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698