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

Unified Diff: base/pending_task.cc

Issue 1886453003: Make PendingTask move-only and pass it by value on retaining params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac test fix Created 4 years, 5 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/pending_task.h ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pending_task.cc
diff --git a/base/pending_task.cc b/base/pending_task.cc
index c0999bab5f325f215b02ba025598f17b0abd84fb..73834bd46071ab61c0f902b599497a72a494c35c 100644
--- a/base/pending_task.cc
+++ b/base/pending_task.cc
@@ -9,9 +9,9 @@
namespace base {
PendingTask::PendingTask(const tracked_objects::Location& posted_from,
- const base::Closure& task)
+ base::Closure task)
: base::TrackingInfo(posted_from, TimeTicks()),
- task(task),
+ task(std::move(task)),
posted_from(posted_from),
sequence_num(0),
nestable(true),
@@ -19,22 +19,24 @@ PendingTask::PendingTask(const tracked_objects::Location& posted_from,
}
PendingTask::PendingTask(const tracked_objects::Location& posted_from,
- const base::Closure& task,
+ base::Closure task,
TimeTicks delayed_run_time,
bool nestable)
: base::TrackingInfo(posted_from, delayed_run_time),
- task(task),
+ task(std::move(task)),
posted_from(posted_from),
sequence_num(0),
nestable(nestable),
is_high_res(false) {
}
-PendingTask::PendingTask(const PendingTask& other) = default;
+PendingTask::PendingTask(PendingTask&& other) = default;
PendingTask::~PendingTask() {
}
+PendingTask& PendingTask::operator=(PendingTask&& other) = default;
+
bool PendingTask::operator<(const PendingTask& other) const {
// Since the top of a priority queue is defined as the "greatest" element, we
// need to invert the comparison here. We want the smaller time to be at the
« no previous file with comments | « base/pending_task.h ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698