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

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

Issue 2076153002: [TaskScheduler] Support TaskRunnerHandles from parallel tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mix_c_Ab
Patch Set: Created 4 years, 6 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
« no previous file with comments | « base/task_scheduler/task.h ('k') | base/task_scheduler/task_tracker.h » ('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_scheduler_impl.h" 5 #include "base/task_scheduler/task_scheduler_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 17 matching lines...) Expand all
28 TaskSchedulerImpl::~TaskSchedulerImpl() { 28 TaskSchedulerImpl::~TaskSchedulerImpl() {
29 #if DCHECK_IS_ON() 29 #if DCHECK_IS_ON()
30 DCHECK(join_for_testing_returned_.IsSignaled()); 30 DCHECK(join_for_testing_returned_.IsSignaled());
31 #endif 31 #endif
32 } 32 }
33 33
34 void TaskSchedulerImpl::PostTaskWithTraits( 34 void TaskSchedulerImpl::PostTaskWithTraits(
35 const tracked_objects::Location& from_here, 35 const tracked_objects::Location& from_here,
36 const TaskTraits& traits, 36 const TaskTraits& traits,
37 const Closure& task) { 37 const Closure& task) {
38 // Post |task| as part of a one-off single-task Sequence. 38 // Although this is a one-off task, still need to create a TaskRunner for it
39 GetThreadPoolForTraits(traits)->PostTaskWithSequence( 39 // to support TaskRunnerHandles in its context.
40 WrapUnique(new Task(from_here, task, traits, TimeDelta())), 40 GetThreadPoolForTraits(traits)
41 make_scoped_refptr(new Sequence), nullptr); 41 ->CreateTaskRunnerWithTraits(traits, ExecutionMode::PARALLEL)
42 ->PostTask(from_here, task);
42 } 43 }
43 44
44 scoped_refptr<TaskRunner> TaskSchedulerImpl::CreateTaskRunnerWithTraits( 45 scoped_refptr<TaskRunner> TaskSchedulerImpl::CreateTaskRunnerWithTraits(
45 const TaskTraits& traits, 46 const TaskTraits& traits,
46 ExecutionMode execution_mode) { 47 ExecutionMode execution_mode) {
47 return GetThreadPoolForTraits(traits)->CreateTaskRunnerWithTraits( 48 return GetThreadPoolForTraits(traits)->CreateTaskRunnerWithTraits(
48 traits, execution_mode); 49 traits, execution_mode);
49 } 50 }
50 51
51 void TaskSchedulerImpl::Shutdown() { 52 void TaskSchedulerImpl::Shutdown() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 153 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
153 sort_key); 154 sort_key);
154 } 155 }
155 156
156 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() { 157 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() {
157 service_thread_->WakeUp(); 158 service_thread_->WakeUp();
158 } 159 }
159 160
160 } // namespace internal 161 } // namespace internal
161 } // namespace base 162 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task.h ('k') | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698