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

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/task_scheduler/scheduler_single_thread_task_runner_manager.cc ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.cc b/base/task_scheduler/scheduler_worker_pool_impl.cc
index 56e1f7b54eb5e55522e94f047dddf0a7333a62ee..9e61bd7323cf8bcf507f9277de9017e6acc9498c 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl.cc
@@ -58,11 +58,11 @@ class SchedulerParallelTaskRunner : public TaskRunner {
// TaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const Closure& closure,
+ Closure closure,
TimeDelta delay) override {
// Post the task as part of a one-off single-task Sequence.
return worker_pool_->PostTaskWithSequence(
- MakeUnique<Task>(from_here, closure, traits_, delay),
+ MakeUnique<Task>(from_here, std::move(closure), traits_, delay),
make_scoped_refptr(new Sequence));
}
@@ -93,9 +93,10 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
// SequencedTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const Closure& closure,
+ Closure closure,
TimeDelta delay) override {
- std::unique_ptr<Task> task(new Task(from_here, closure, traits_, delay));
+ std::unique_ptr<Task> task(
+ new Task(from_here, std::move(closure), traits_, delay));
task->sequenced_task_runner_ref = this;
// Post the task as part of |sequence_|.
@@ -103,10 +104,10 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const Closure& closure,
+ Closure closure,
base::TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
- return PostDelayedTask(from_here, closure, delay);
+ return PostDelayedTask(from_here, std::move(closure), delay);
}
bool RunsTasksOnCurrentThread() const override {
« no previous file with comments | « base/task_scheduler/scheduler_single_thread_task_runner_manager.cc ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698