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

Side by Side Diff: base/sequenced_task_runner.h

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: s/base::ResetAndReturn/std::move/ 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_ 5 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_
6 #define BASE_SEQUENCED_TASK_RUNNER_H_ 6 #define BASE_SEQUENCED_TASK_RUNNER_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/callback.h"
9 #include "base/sequenced_task_runner_helpers.h" 10 #include "base/sequenced_task_runner_helpers.h"
10 #include "base/task_runner.h" 11 #include "base/task_runner.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 // A SequencedTaskRunner is a subclass of TaskRunner that provides 15 // A SequencedTaskRunner is a subclass of TaskRunner that provides
15 // additional guarantees on the order that tasks are started, as well 16 // additional guarantees on the order that tasks are started, as well
16 // as guarantees on when tasks are in sequence, i.e. one task finishes 17 // as guarantees on when tasks are in sequence, i.e. one task finishes
17 // before the other one starts. 18 // before the other one starts.
18 // 19 //
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // A simple corollary is that posting a task as non-nestable can 103 // A simple corollary is that posting a task as non-nestable can
103 // only delay when the task gets run. That is, posting a task as 104 // only delay when the task gets run. That is, posting a task as
104 // non-nestable may not affect when the task gets run, or it could 105 // non-nestable may not affect when the task gets run, or it could
105 // make it run later than it normally would, but it won't make it 106 // make it run later than it normally would, but it won't make it
106 // run earlier than it normally would. 107 // run earlier than it normally would.
107 108
108 // TODO(akalin): Get rid of the boolean return value for the methods 109 // TODO(akalin): Get rid of the boolean return value for the methods
109 // below. 110 // below.
110 111
111 bool PostNonNestableTask(const tracked_objects::Location& from_here, 112 bool PostNonNestableTask(const tracked_objects::Location& from_here,
112 const Closure& task); 113 Closure task);
113 114
114 virtual bool PostNonNestableDelayedTask( 115 virtual bool PostNonNestableDelayedTask(
115 const tracked_objects::Location& from_here, 116 const tracked_objects::Location& from_here,
116 const Closure& task, 117 Closure task,
117 base::TimeDelta delay) = 0; 118 base::TimeDelta delay) = 0;
118 119
119 // Submits a non-nestable task to delete the given object. Returns 120 // Submits a non-nestable task to delete the given object. Returns
120 // true if the object may be deleted at some point in the future, 121 // true if the object may be deleted at some point in the future,
121 // and false if the object definitely will not be deleted. 122 // and false if the object definitely will not be deleted.
122 template <class T> 123 template <class T>
123 bool DeleteSoon(const tracked_objects::Location& from_here, 124 bool DeleteSoon(const tracked_objects::Location& from_here,
124 const T* object) { 125 const T* object) {
125 return DeleteOrReleaseSoonInternal(from_here, &DeleteHelper<T>::DoDelete, 126 return DeleteOrReleaseSoonInternal(from_here, &DeleteHelper<T>::DoDelete,
126 object); 127 object);
(...skipping 30 matching lines...) Expand all
157 if (ptr) 158 if (ptr)
158 task_runner_->DeleteSoon(FROM_HERE, ptr); 159 task_runner_->DeleteSoon(FROM_HERE, ptr);
159 } 160 }
160 161
161 scoped_refptr<SequencedTaskRunner> task_runner_; 162 scoped_refptr<SequencedTaskRunner> task_runner_;
162 }; 163 };
163 164
164 } // namespace base 165 } // namespace base
165 166
166 #endif // BASE_SEQUENCED_TASK_RUNNER_H_ 167 #endif // BASE_SEQUENCED_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698