Chromium Code Reviews| Index: base/bind.h |
| diff --git a/base/bind.h b/base/bind.h |
| index 9cf65b67764b0cbcb393cd392f6fdb480d57496b..79723c8acb8c61df1ea7bf22de8a35832bf54999 100644 |
| --- a/base/bind.h |
| +++ b/base/bind.h |
| @@ -24,10 +24,10 @@ |
| namespace base { |
| +// Default Bind. |
| template <typename Functor, typename... Args> |
| -inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind( |
| - Functor&& functor, |
| - Args&&... args) { |
| +inline base::Callback<MakeUnboundRunType<Functor, Args...>> |
|
hiroshige
2016/07/04 10:04:22
It might be unclear for developers which Bind()/Ca
tzik
2016/07/06 07:36:13
Hmm, I think it's still not ready to use for devs,
hiroshige
2016/08/12 06:00:47
Placing new variants in internal namespace looks g
|
| +Bind(Functor&& functor, Args&&... args) { |
| using BindState = internal::MakeBindStateType<Functor, Args...>; |
| using UnboundRunType = MakeUnboundRunType<Functor, Args...>; |
| using Invoker = internal::Invoker<BindState, UnboundRunType>; |
| @@ -38,6 +38,34 @@ inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind( |
| &Invoker::Run); |
| } |
| +// Bind as RepeatingCallback. |
| +template <typename Functor, typename... Args> |
| +inline base::RepeatingCallback<MakeUnboundRunType<Functor, Args...>> |
| +BindRepeating(Functor&& functor, Args&&... args) { |
| + using BindState = internal::MakeBindStateType<Functor, Args...>; |
| + using UnboundRunType = MakeUnboundRunType<Functor, Args...>; |
| + using Invoker = internal::Invoker<BindState, UnboundRunType>; |
| + |
| + using CallbackType = RepeatingCallback<UnboundRunType>; |
| + return CallbackType(new BindState(std::forward<Functor>(functor), |
| + std::forward<Args>(args)...), |
| + &Invoker::Run); |
| +} |
| + |
| +// Bind as OneShotCallback. |
| +template <typename Functor, typename... Args> |
| +inline base::OneShotCallback<MakeUnboundRunType<Functor, Args...>> |
| +BindOneShot(Functor&& functor, Args&&... args) { |
| + using BindState = internal::MakeBindStateType<Functor, Args...>; |
| + using UnboundRunType = MakeUnboundRunType<Functor, Args...>; |
| + using Invoker = internal::Invoker<BindState, UnboundRunType>; |
| + |
| + using CallbackType = OneShotCallback<UnboundRunType>; |
| + return CallbackType(new BindState(std::forward<Functor>(functor), |
| + std::forward<Args>(args)...), |
| + &Invoker::RunOneShot); |
| +} |
| + |
| } // namespace base |
| #endif // BASE_BIND_H_ |