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

Unified Diff: base/callback.h.pump

Issue 9717021: Make Callback::Reset() return a copy to support use-cases where Run() ends up modifying |*this|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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/callback.h.pump
diff --git a/base/callback.h.pump b/base/callback.h.pump
index ef65e8322f21c2b969538b5148c12935f7492fde..57db9d03519c641a93e67cb31b32716b988f26e1 100644
--- a/base/callback.h.pump
+++ b/base/callback.h.pump
@@ -44,6 +44,10 @@ $var MAX_ARITY = 7
// The reason to pass via a const-reference is to avoid unnecessary
// AddRef/Release pairs to the internal state.
//
+// If a Callback variable must be empty during the Run() of a previous value of
+// that variable, use ResetAndRun(). E.g. if MyClass has a member variable
+// Callback which gets set as a side-effect of Run()'ing the Callback (to
+// something else), ResetAndRun() can be handy.
//
// EXAMPLE USAGE:
//
@@ -292,6 +296,16 @@ $for ARG ,
[[internal::CallbackForward(a$(ARG))]]);
}
+
+ R ResetAndRun($for ARG ,
+ [[typename internal::CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
+ Callback<RunType> tmp(*this);
+ Reset();
+ tmp.Run(
+$for ARG ,
+ [[internal::CallbackForward(a$(ARG))]]);
+ }
+
private:
typedef R(*PolymorphicInvoke)(
internal::BindStateBase*[[]]
« no previous file with comments | « base/callback.h ('k') | base/callback_unittest.cc » ('j') | base/callback_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698