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

Unified Diff: base/threading/worker_pool_posix.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: Created 4 years, 8 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
Index: base/threading/worker_pool_posix.cc
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index dcebe0ab7d2fb704d118a6f797a272ef6c1c0aeb..40faeb692eb25678dee00a739c2481453edad0c7 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -150,8 +150,8 @@ void PosixDynamicThreadPool::AddTask(PendingTask* pending_task) {
DCHECK(!terminated_)
<< "This thread pool is already terminated. Do not post new tasks.";
- pending_tasks_.push(*pending_task);
- pending_task->task.Reset();
+ pending_tasks_.push(std::move(*pending_task));
+ DCHECK(pending_task->task.is_null());
Sami 2016/04/13 11:33:00 Ditto.
tzik 2016/04/13 14:35:37 Done.
// We have enough worker threads.
if (static_cast<size_t>(num_idle_threads_) >= pending_tasks_.size()) {
@@ -186,7 +186,7 @@ PendingTask PosixDynamicThreadPool::WaitForTask() {
}
}
- PendingTask pending_task = pending_tasks_.front();
+ PendingTask pending_task = std::move(pending_tasks_.front());
pending_tasks_.pop();
return pending_task;
}

Powered by Google App Engine
This is Rietveld 408576698