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

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

Issue 2678303002: Pass Callback by value on PostTaskAndReply family (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | base/threading/post_task_and_reply_impl.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/post_task.h" 5 #include "base/task_scheduler/post_task.h"
6 6
7 #include <utility>
8
7 #include "base/task_scheduler/task_scheduler.h" 9 #include "base/task_scheduler/task_scheduler.h"
8 #include "base/threading/post_task_and_reply_impl.h" 10 #include "base/threading/post_task_and_reply_impl.h"
9 11
10 namespace base { 12 namespace base {
11 13
12 namespace { 14 namespace {
13 15
14 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { 16 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
15 public: 17 public:
16 explicit PostTaskAndReplyTaskRunner(const TaskTraits& traits) 18 explicit PostTaskAndReplyTaskRunner(const TaskTraits& traits)
(...skipping 16 matching lines...) Expand all
33 PostDelayedTask(from_here, task, TimeDelta()); 35 PostDelayedTask(from_here, task, TimeDelta());
34 } 36 }
35 37
36 void PostDelayedTask(const tracked_objects::Location& from_here, 38 void PostDelayedTask(const tracked_objects::Location& from_here,
37 const Closure& task, 39 const Closure& task,
38 TimeDelta delay) { 40 TimeDelta delay) {
39 PostDelayedTaskWithTraits(from_here, TaskTraits(), task, delay); 41 PostDelayedTaskWithTraits(from_here, TaskTraits(), task, delay);
40 } 42 }
41 43
42 void PostTaskAndReply(const tracked_objects::Location& from_here, 44 void PostTaskAndReply(const tracked_objects::Location& from_here,
43 const Closure& task, 45 Closure task,
44 const Closure& reply) { 46 Closure reply) {
45 PostTaskWithTraitsAndReply(from_here, TaskTraits(), task, reply); 47 PostTaskWithTraitsAndReply(from_here, TaskTraits(), std::move(task),
48 std::move(reply));
46 } 49 }
47 50
48 void PostTaskWithTraits(const tracked_objects::Location& from_here, 51 void PostTaskWithTraits(const tracked_objects::Location& from_here,
49 const TaskTraits& traits, 52 const TaskTraits& traits,
50 const Closure& task) { 53 const Closure& task) {
51 PostDelayedTaskWithTraits(from_here, traits, task, TimeDelta()); 54 PostDelayedTaskWithTraits(from_here, traits, task, TimeDelta());
52 } 55 }
53 56
54 void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here, 57 void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
55 const TaskTraits& traits, 58 const TaskTraits& traits,
56 const Closure& task, 59 const Closure& task,
57 TimeDelta delay) { 60 TimeDelta delay) {
58 TaskScheduler::GetInstance()->PostDelayedTaskWithTraits(from_here, traits, 61 TaskScheduler::GetInstance()->PostDelayedTaskWithTraits(from_here, traits,
59 task, delay); 62 task, delay);
60 } 63 }
61 64
62 void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here, 65 void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here,
63 const TaskTraits& traits, 66 const TaskTraits& traits,
64 const Closure& task, 67 Closure task,
65 const Closure& reply) { 68 Closure reply) {
66 PostTaskAndReplyTaskRunner(traits).PostTaskAndReply(from_here, task, reply); 69 PostTaskAndReplyTaskRunner(traits).PostTaskAndReply(
70 from_here, std::move(task), std::move(reply));
67 } 71 }
68 72
69 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(const TaskTraits& traits) { 73 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(const TaskTraits& traits) {
70 return TaskScheduler::GetInstance()->CreateTaskRunnerWithTraits(traits); 74 return TaskScheduler::GetInstance()->CreateTaskRunnerWithTraits(traits);
71 } 75 }
72 76
73 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits( 77 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits(
74 const TaskTraits& traits) { 78 const TaskTraits& traits) {
75 return TaskScheduler::GetInstance()->CreateSequencedTaskRunnerWithTraits( 79 return TaskScheduler::GetInstance()->CreateSequencedTaskRunnerWithTraits(
76 traits); 80 traits);
77 } 81 }
78 82
79 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits( 83 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits(
80 const TaskTraits& traits) { 84 const TaskTraits& traits) {
81 return TaskScheduler::GetInstance()->CreateSingleThreadTaskRunnerWithTraits( 85 return TaskScheduler::GetInstance()->CreateSingleThreadTaskRunnerWithTraits(
82 traits); 86 traits);
83 } 87 }
84 88
85 } // namespace base 89 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | base/threading/post_task_and_reply_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698