Remove unnecessary copies from AsyncInvoke

Currently, the way the AsyncInvoke is implemented, the lambda invoked is copied multiple times. This causes two problems: (1) a reduced performance where captured variables are copied unnecessarily, (2) lambdas with non-copyable captures are not possible to invoke.

This cl attempts to address both points.

Change-Id: I8d907287d6e4851330d469f184760d165fa8bc08
Bug: webrtc:9028
Reviewed-on: https://webrtc-review.googlesource.com/61346
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22471}
diff --git a/rtc_base/asyncinvoker-inl.h b/rtc_base/asyncinvoker-inl.h
index 073d5bf..0d546b1 100644
--- a/rtc_base/asyncinvoker-inl.h
+++ b/rtc_base/asyncinvoker-inl.h
@@ -49,13 +49,13 @@
 class FireAndForgetAsyncClosure : public AsyncClosure {
  public:
   explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker,
-                                     const FunctorT& functor)
-      : AsyncClosure(invoker), functor_(functor) {}
+                                     FunctorT&& functor)
+      : AsyncClosure(invoker), functor_(std::forward<FunctorT>(functor)) {}
   virtual void Execute() {
     functor_();
   }
  private:
-  FunctorT functor_;
+  typename std::decay<FunctorT>::type functor_;
 };
 
 }  // namespace rtc