1 // This file was GENERATED by command:
2 // pump.py callback.h.pump
3 // DO NOT EDIT BY HAND!!!
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file.
10 #ifndef BASE_CALLBACK_H_
11 #define BASE_CALLBACK_H_
14 #include "base/callback_forward.h"
15 #include "base/callback_internal.h"
16 #include "base/template_util.h"
18 // NOTE: Header files that do not require the full definition of Callback or
19 // Closure should #include "base/callback_forward.h" instead of this file.
21 // New, super-duper, unified Callback system. This will eventually replace
22 // NewRunnableMethod, NewRunnableFunction, CreateFunctor, and CreateCallback
23 // systems currently in the Chromium code base.
27 // The templated Callback class is a generalized function object. Together
28 // with the Bind() function in bind.h, they provide a type-safe method for
29 // performing currying of arguments, and creating a "closure."
31 // In programming languages, a closure is a first-class function where all its
32 // parameters have been bound (usually via currying). Closures are well
33 // suited for representing, and passing around a unit of delayed execution.
34 // They are used in Chromium code to schedule tasks on different MessageLoops.
37 // MEMORY MANAGEMENT AND PASSING
39 // The Callback objects themselves should be passed by const-reference, and
40 // stored by copy. They internally store their state via a refcounted class
41 // and thus do not need to be deleted.
43 // The reason to pass via a const-reference is to avoid unnecessary
44 // AddRef/Release pairs to the internal state.
49 // /* Binding a normal function. */
50 // int Return5() { return 5; }
51 // base::Callback<int(void)> func_cb = base::Bind(&Return5);
52 // LOG(INFO) << func_cb.Run(); // Prints 5.
54 // void PrintHi() { LOG(INFO) << "hi."; }
55 // base::Closure void_func_cb = base::Bind(&PrintHi);
56 // void_func_cb.Run(); // Prints: hi.
58 // /* Binding a class method. */
59 // class Ref : public RefCountedThreadSafe<Ref> {
61 // int Foo() { return 3; }
62 // void PrintBye() { LOG(INFO) << "bye."; }
64 // scoped_refptr<Ref> ref = new Ref();
65 // base::Callback<int(void)> ref_cb = base::Bind(&Ref::Foo, ref.get());
66 // LOG(INFO) << ref_cb.Run(); // Prints out 3.
68 // base::Closure void_ref_cb = base::Bind(&Ref::PrintBye, ref.get());
69 // void_ref_cb.Run(); // Prints: bye.
71 // /* Binding a class method in a non-refcounted class.
73 // * WARNING: You must be sure the referee outlives the callback!
74 // * This is particularly important if you post a closure to a
75 // * MessageLoop because then it becomes hard to know what the
76 // * lifetime of the referee needs to be.
80 // int Foo() { return 4; }
81 // void PrintWhy() { LOG(INFO) << "why???"; }
84 // base::Callback<int(void)> base::no_ref_cb =
85 // base::Bind(&NoRef::Foo, base::Unretained(&no_ref));
86 // LOG(INFO) << ref_cb.Run(); // Prints out 4.
88 // base::Closure void_no_ref_cb =
89 // base::Bind(&NoRef::PrintWhy, base::Unretained(no_ref));
90 // void_no_ref_cb.Run(); // Prints: why???
92 // /* Binding a reference. */
93 // int Identity(int n) { return n; }
95 // base::Callback<int(void)> bound_copy_cb = base::Bind(&Identity, value);
96 // base::Callback<int(void)> bound_ref_cb =
97 // base::Bind(&Identity, base::ConstRef(value));
98 // LOG(INFO) << bound_copy_cb.Run(); // Prints 1.
99 // LOG(INFO) << bound_ref_cb.Run(); // Prints 1.
101 // LOG(INFO) << bound_copy_cb.Run(); // Prints 1.
102 // LOG(INFO) << bound_ref_cb.Run(); // Prints 2.
104 // /* Currying parameters. This also works for methods. */
105 // int Sum(int a, int b, int c) {
108 // base::Callback<int(int, int)> sum3_cb = base::Bind(&Sum, 3);
109 // LOG(INFO) << sum3_cb.Run(4, 5); // Prints 12.
111 // base::Callback<int(int)> sum7_cb = base::Bind(&Sum, 3, 4);
112 // LOG(INFO) << sum7_cb.Run(10); // Prints 17.
115 // WHERE IS THIS DESIGN FROM:
117 // The design Callback and Bind is heavily influenced by C++'s
118 // tr1::function/tr1::bind, and by the "Google Callback" system used inside
122 // HOW THE IMPLEMENTATION WORKS:
124 // There are three main components to the system:
125 // 1) The Callback classes.
126 // 2) The Bind() functions.
127 // 3) The arguments wrappers (eg., Unretained() and ConstRef()).
129 // The Callback classes represent a generic function pointer. Internally,
130 // it stores a refcounted piece of state that represents the target function
131 // and all its bound parameters. Each Callback specialization has a templated
132 // constructor that takes an BindStateHolder<> object. In the context of
133 // the constructor, the static type of this BindStateHolder<> object
134 // uniquely identifies the function it is representing, all its bound
135 // parameters, and a DoInvoke() that is capable of invoking the target.
137 // Callback's constructor is takes the BindStateHolder<> that has the
138 // full static type and erases the target function type, and the bound
139 // parameters. It does this by storing a pointer to the specific DoInvoke()
140 // function, and upcasting the state of BindStateHolder<> to a
141 // BindStateBase. This is safe as long as this BindStateBase pointer
142 // is only used with the stored DoInvoke() pointer.
144 // To create BindStateHolder<> objects, we use the Bind() functions.
145 // These functions, along with a set of internal templates, are reponsible for
147 // - Unwrapping the function signature into return type, and parameters
148 // - Determining the number of parameters that are bound
149 // - Creating the storage for the bound parameters
150 // - Performing compile-time asserts to avoid error-prone behavior
151 // - Returning an BindStateHolder<> with an DoInvoke() that has an arity
152 // matching the number of unbound parameters, and knows the correct
153 // refcounting semantics for the target object if we are binding a class
156 // The Bind functions do the above using type-inference, and template
159 // By default Bind() will store copies of all bound parameters, and attempt
160 // to refcount a target object if the function being bound is a class method.
162 // To change this behavior, we introduce a set of argument wrappers
163 // (eg. Unretained(), and ConstRef()). These are simple container templates
164 // that are passed by value, and wrap a pointer to argument. See the
165 // file-level comment in base/bind_helpers.h for more info.
167 // These types are passed to the Unwrap() functions, and the MaybeRefcount()
168 // functions respectively to modify the behavior of Bind(). The Unwrap()
169 // and MaybeRefcount() functions change behavior by doing partial
170 // specialization based on whether or not a parameter is a wrapper type.
172 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
175 // WHY NOT TR1 FUNCTION/BIND?
177 // Direct use of tr1::function and tr1::bind was considered, but ultimately
178 // rejected because of the number of copy constructors invocations involved
179 // in the binding of arguments during construction, and the forwarding of
180 // arguments during invocation. These copies will no longer be an issue in
181 // C++0x because C++0x will support rvalue reference allowing for the compiler
182 // to avoid these copies. However, waiting for C++0x is not an option.
184 // Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
185 // tr1::bind call itself will invoke a non-trivial copy constructor three times
186 // for each bound parameter. Also, each when passing a tr1::function, each
187 // bound argument will be copied again.
189 // In addition to the copies taken at binding and invocation, copying a
190 // tr1::function causes a copy to be made of all the bound parameters and
193 // Furthermore, in Chromium, it is desirable for the Callback to take a
194 // reference on a target object when representing a class method call. This
195 // is not supported by tr1.
197 // Lastly, tr1::function and tr1::bind has a more general and flexible API.
198 // This includes things like argument reordering by use of
199 // tr1::bind::placeholder, support for non-const reference parameters, and some
200 // limited amount of subtyping of the tr1::function object (eg.,
201 // tr1::function<int(int)> is convertible to tr1::function<void(int)>).
203 // These are not features that are required in Chromium. Some of them, such as
204 // allowing for reference parameters, and subtyping of functions, may actually
205 // become a source of errors. Removing support for these features actually
206 // allows for a simpler implementation, and a terser Currying API.
209 // WHY NOT GOOGLE CALLBACKS?
211 // The Google callback system also does not support refcounting. Furthermore,
212 // its implementation has a number of strange edge cases with respect to type
213 // conversion of its arguments. In particular, the argument's constness must
214 // at times match exactly the function signature, or the type-inference might
215 // break. Given the above, writing a custom solution was easier.
218 // MISSING FUNCTIONALITY
219 // - Invoking the return of Bind. Bind(&foo).Run() does not work;
220 // - Binding arrays to functions that take a non-const pointer.
222 // void Foo(const char* ptr);
223 // void Bar(char* ptr);
224 // Bind(&Foo, "test");
225 // Bind(&Bar, "test"); // This fails because ptr is not const.
229 // First, we forward declare the Callback class template. This informs the
230 // compiler that the template only has 1 type parameter which is the function
231 // signature that the Callback is representing.
233 // After this, create template specializations for 0-7 parameters. Note that
234 // even though the template typelist grows, the specialization still
235 // only has one type: the function signature.
237 // If you are thinking of forward declaring Callback in your own header file,
238 // please include "base/callback_forward.h" instead.
239 template <typename Sig
>
242 template <typename R
>
243 class Callback
<R(void)> : public internal::CallbackBase
{
245 typedef R(RunType
)();
247 Callback() : CallbackBase(NULL
, NULL
) { }
249 // We pass BindStateHolder by const ref to avoid incurring an
250 // unnecessary AddRef/Unref pair even though we will modify the object.
251 // We cannot use a normal reference because the compiler will warn
252 // since this is often used on a return value, which is a temporary.
254 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
255 // return the exact Callback<> type. See base/bind.h for details.
256 template <typename T
>
257 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
258 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
259 // Force the assignment to a location variable of PolymorphicInvoke
260 // so the compiler will typecheck that the passed in Run() method has
262 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
263 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
266 bool Equals(const Callback
& other
) const {
267 return CallbackBase::Equals(other
);
271 PolymorphicInvoke f
=
272 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
274 return f(bind_state_
.get());
278 typedef R(*PolymorphicInvoke
)(
279 internal::BindStateBase
*);
283 template <typename R
, typename A1
>
284 class Callback
<R(A1
)> : public internal::CallbackBase
{
286 typedef R(RunType
)(A1
);
288 Callback() : CallbackBase(NULL
, NULL
) { }
290 // We pass BindStateHolder by const ref to avoid incurring an
291 // unnecessary AddRef/Unref pair even though we will modify the object.
292 // We cannot use a normal reference because the compiler will warn
293 // since this is often used on a return value, which is a temporary.
295 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
296 // return the exact Callback<> type. See base/bind.h for details.
297 template <typename T
>
298 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
299 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
300 // Force the assignment to a location variable of PolymorphicInvoke
301 // so the compiler will typecheck that the passed in Run() method has
303 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
304 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
307 bool Equals(const Callback
& other
) const {
308 return CallbackBase::Equals(other
);
311 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
) const {
312 PolymorphicInvoke f
=
313 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
315 return f(bind_state_
.get(), a1
);
319 typedef R(*PolymorphicInvoke
)(
320 internal::BindStateBase
*,
321 typename
internal::CallbackParamTraits
<A1
>::ForwardType
);
325 template <typename R
, typename A1
, typename A2
>
326 class Callback
<R(A1
, A2
)> : public internal::CallbackBase
{
328 typedef R(RunType
)(A1
, A2
);
330 Callback() : CallbackBase(NULL
, NULL
) { }
332 // We pass BindStateHolder by const ref to avoid incurring an
333 // unnecessary AddRef/Unref pair even though we will modify the object.
334 // We cannot use a normal reference because the compiler will warn
335 // since this is often used on a return value, which is a temporary.
337 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
338 // return the exact Callback<> type. See base/bind.h for details.
339 template <typename T
>
340 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
341 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
342 // Force the assignment to a location variable of PolymorphicInvoke
343 // so the compiler will typecheck that the passed in Run() method has
345 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
346 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
349 bool Equals(const Callback
& other
) const {
350 return CallbackBase::Equals(other
);
353 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
354 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
) const {
355 PolymorphicInvoke f
=
356 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
358 return f(bind_state_
.get(), a1
,
363 typedef R(*PolymorphicInvoke
)(
364 internal::BindStateBase
*,
365 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
366 typename
internal::CallbackParamTraits
<A2
>::ForwardType
);
370 template <typename R
, typename A1
, typename A2
, typename A3
>
371 class Callback
<R(A1
, A2
, A3
)> : public internal::CallbackBase
{
373 typedef R(RunType
)(A1
, A2
, A3
);
375 Callback() : CallbackBase(NULL
, NULL
) { }
377 // We pass BindStateHolder by const ref to avoid incurring an
378 // unnecessary AddRef/Unref pair even though we will modify the object.
379 // We cannot use a normal reference because the compiler will warn
380 // since this is often used on a return value, which is a temporary.
382 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
383 // return the exact Callback<> type. See base/bind.h for details.
384 template <typename T
>
385 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
386 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
387 // Force the assignment to a location variable of PolymorphicInvoke
388 // so the compiler will typecheck that the passed in Run() method has
390 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
391 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
394 bool Equals(const Callback
& other
) const {
395 return CallbackBase::Equals(other
);
398 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
399 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
,
400 typename
internal::CallbackParamTraits
<A3
>::ForwardType a3
) const {
401 PolymorphicInvoke f
=
402 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
404 return f(bind_state_
.get(), a1
,
410 typedef R(*PolymorphicInvoke
)(
411 internal::BindStateBase
*,
412 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
413 typename
internal::CallbackParamTraits
<A2
>::ForwardType
,
414 typename
internal::CallbackParamTraits
<A3
>::ForwardType
);
418 template <typename R
, typename A1
, typename A2
, typename A3
, typename A4
>
419 class Callback
<R(A1
, A2
, A3
, A4
)> : public internal::CallbackBase
{
421 typedef R(RunType
)(A1
, A2
, A3
, A4
);
423 Callback() : CallbackBase(NULL
, NULL
) { }
425 // We pass BindStateHolder by const ref to avoid incurring an
426 // unnecessary AddRef/Unref pair even though we will modify the object.
427 // We cannot use a normal reference because the compiler will warn
428 // since this is often used on a return value, which is a temporary.
430 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
431 // return the exact Callback<> type. See base/bind.h for details.
432 template <typename T
>
433 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
434 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
435 // Force the assignment to a location variable of PolymorphicInvoke
436 // so the compiler will typecheck that the passed in Run() method has
438 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
439 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
442 bool Equals(const Callback
& other
) const {
443 return CallbackBase::Equals(other
);
446 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
447 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
,
448 typename
internal::CallbackParamTraits
<A3
>::ForwardType a3
,
449 typename
internal::CallbackParamTraits
<A4
>::ForwardType a4
) const {
450 PolymorphicInvoke f
=
451 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
453 return f(bind_state_
.get(), a1
,
460 typedef R(*PolymorphicInvoke
)(
461 internal::BindStateBase
*,
462 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
463 typename
internal::CallbackParamTraits
<A2
>::ForwardType
,
464 typename
internal::CallbackParamTraits
<A3
>::ForwardType
,
465 typename
internal::CallbackParamTraits
<A4
>::ForwardType
);
469 template <typename R
, typename A1
, typename A2
, typename A3
, typename A4
,
471 class Callback
<R(A1
, A2
, A3
, A4
, A5
)> : public internal::CallbackBase
{
473 typedef R(RunType
)(A1
, A2
, A3
, A4
, A5
);
475 Callback() : CallbackBase(NULL
, NULL
) { }
477 // We pass BindStateHolder by const ref to avoid incurring an
478 // unnecessary AddRef/Unref pair even though we will modify the object.
479 // We cannot use a normal reference because the compiler will warn
480 // since this is often used on a return value, which is a temporary.
482 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
483 // return the exact Callback<> type. See base/bind.h for details.
484 template <typename T
>
485 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
486 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
487 // Force the assignment to a location variable of PolymorphicInvoke
488 // so the compiler will typecheck that the passed in Run() method has
490 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
491 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
494 bool Equals(const Callback
& other
) const {
495 return CallbackBase::Equals(other
);
498 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
499 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
,
500 typename
internal::CallbackParamTraits
<A3
>::ForwardType a3
,
501 typename
internal::CallbackParamTraits
<A4
>::ForwardType a4
,
502 typename
internal::CallbackParamTraits
<A5
>::ForwardType a5
) const {
503 PolymorphicInvoke f
=
504 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
506 return f(bind_state_
.get(), a1
,
514 typedef R(*PolymorphicInvoke
)(
515 internal::BindStateBase
*,
516 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
517 typename
internal::CallbackParamTraits
<A2
>::ForwardType
,
518 typename
internal::CallbackParamTraits
<A3
>::ForwardType
,
519 typename
internal::CallbackParamTraits
<A4
>::ForwardType
,
520 typename
internal::CallbackParamTraits
<A5
>::ForwardType
);
524 template <typename R
, typename A1
, typename A2
, typename A3
, typename A4
,
525 typename A5
, typename A6
>
526 class Callback
<R(A1
, A2
, A3
, A4
, A5
, A6
)> : public internal::CallbackBase
{
528 typedef R(RunType
)(A1
, A2
, A3
, A4
, A5
, A6
);
530 Callback() : CallbackBase(NULL
, NULL
) { }
532 // We pass BindStateHolder by const ref to avoid incurring an
533 // unnecessary AddRef/Unref pair even though we will modify the object.
534 // We cannot use a normal reference because the compiler will warn
535 // since this is often used on a return value, which is a temporary.
537 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
538 // return the exact Callback<> type. See base/bind.h for details.
539 template <typename T
>
540 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
541 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
542 // Force the assignment to a location variable of PolymorphicInvoke
543 // so the compiler will typecheck that the passed in Run() method has
545 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
546 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
549 bool Equals(const Callback
& other
) const {
550 return CallbackBase::Equals(other
);
553 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
554 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
,
555 typename
internal::CallbackParamTraits
<A3
>::ForwardType a3
,
556 typename
internal::CallbackParamTraits
<A4
>::ForwardType a4
,
557 typename
internal::CallbackParamTraits
<A5
>::ForwardType a5
,
558 typename
internal::CallbackParamTraits
<A6
>::ForwardType a6
) const {
559 PolymorphicInvoke f
=
560 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
562 return f(bind_state_
.get(), a1
,
571 typedef R(*PolymorphicInvoke
)(
572 internal::BindStateBase
*,
573 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
574 typename
internal::CallbackParamTraits
<A2
>::ForwardType
,
575 typename
internal::CallbackParamTraits
<A3
>::ForwardType
,
576 typename
internal::CallbackParamTraits
<A4
>::ForwardType
,
577 typename
internal::CallbackParamTraits
<A5
>::ForwardType
,
578 typename
internal::CallbackParamTraits
<A6
>::ForwardType
);
582 template <typename R
, typename A1
, typename A2
, typename A3
, typename A4
,
583 typename A5
, typename A6
, typename A7
>
584 class Callback
<R(A1
, A2
, A3
, A4
, A5
, A6
, A7
)> : public internal::CallbackBase
{
586 typedef R(RunType
)(A1
, A2
, A3
, A4
, A5
, A6
, A7
);
588 Callback() : CallbackBase(NULL
, NULL
) { }
590 // We pass BindStateHolder by const ref to avoid incurring an
591 // unnecessary AddRef/Unref pair even though we will modify the object.
592 // We cannot use a normal reference because the compiler will warn
593 // since this is often used on a return value, which is a temporary.
595 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
596 // return the exact Callback<> type. See base/bind.h for details.
597 template <typename T
>
598 Callback(const internal::BindStateHolder
<T
>& bind_state_holder
)
599 : CallbackBase(NULL
, &bind_state_holder
.bind_state_
) {
600 // Force the assignment to a location variable of PolymorphicInvoke
601 // so the compiler will typecheck that the passed in Run() method has
603 PolymorphicInvoke invoke_func
= &T::InvokerType::Run
;
604 polymorphic_invoke_
= reinterpret_cast<InvokeFuncStorage
>(invoke_func
);
607 bool Equals(const Callback
& other
) const {
608 return CallbackBase::Equals(other
);
611 R
Run(typename
internal::CallbackParamTraits
<A1
>::ForwardType a1
,
612 typename
internal::CallbackParamTraits
<A2
>::ForwardType a2
,
613 typename
internal::CallbackParamTraits
<A3
>::ForwardType a3
,
614 typename
internal::CallbackParamTraits
<A4
>::ForwardType a4
,
615 typename
internal::CallbackParamTraits
<A5
>::ForwardType a5
,
616 typename
internal::CallbackParamTraits
<A6
>::ForwardType a6
,
617 typename
internal::CallbackParamTraits
<A7
>::ForwardType a7
) const {
618 PolymorphicInvoke f
=
619 reinterpret_cast<PolymorphicInvoke
>(polymorphic_invoke_
);
621 return f(bind_state_
.get(), a1
,
631 typedef R(*PolymorphicInvoke
)(
632 internal::BindStateBase
*,
633 typename
internal::CallbackParamTraits
<A1
>::ForwardType
,
634 typename
internal::CallbackParamTraits
<A2
>::ForwardType
,
635 typename
internal::CallbackParamTraits
<A3
>::ForwardType
,
636 typename
internal::CallbackParamTraits
<A4
>::ForwardType
,
637 typename
internal::CallbackParamTraits
<A5
>::ForwardType
,
638 typename
internal::CallbackParamTraits
<A6
>::ForwardType
,
639 typename
internal::CallbackParamTraits
<A7
>::ForwardType
);
644 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it
645 // will be used in a lot of APIs with delayed execution.
646 typedef Callback
<void(void)> Closure
;
650 #endif // BASE_CALLBACK_H