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

Unified Diff: base/threading/post_task_and_reply_impl.cc

Issue 2657603004: Clear PostTaskAndReply task on the destination thread (3) (Closed)
Patch Set: reorder delete_flag check. +comment 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
Index: base/threading/post_task_and_reply_impl.cc
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc
index d16f8bd22590e857cb65c9b3cd5d9d7db4f3132e..802de8c3c736932223b0bcf078faeb123b780e72 100644
--- a/base/threading/post_task_and_reply_impl.cc
+++ b/base/threading/post_task_and_reply_impl.cc
@@ -39,12 +39,11 @@ class PostTaskAndReplyRelay {
~PostTaskAndReplyRelay() {
DCHECK(sequence_checker_.CalledOnValidSequence());
- task_.Reset();
- reply_.Reset();
}
void RunTaskAndPostReply() {
task_.Run();
+ task_.Reset();
origin_task_runner_->PostTask(
from_here_, Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
base::Unretained(this)));
@@ -54,10 +53,10 @@ class PostTaskAndReplyRelay {
void RunReplyAndSelfDestruct() {
DCHECK(sequence_checker_.CalledOnValidSequence());
- // Force |task_| to be released before |reply_| is to ensure that no one
- // accidentally depends on |task_| keeping one of its arguments alive while
- // |reply_| is executing.
- task_.Reset();
+ // Ensure |task_| has already been released before |reply_| to ensure that
+ // no one accidentally depends on |task_| keeping one of its arguments alive
+ // while |reply_| is executing.
+ DCHECK(!task_);
reply_.Run();
« no previous file with comments | « base/message_loop/message_loop_task_runner_unittest.cc ('k') | base/threading/post_task_and_reply_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698