folly/futures: replace MoveWrappers with generalised lambda capture
Summary:Now that folly::Future uses folly::Function, we can use non-copyable
callbacks. That allows us to get rid of folly::MoveWrapper in the
implementaion.
This diff also enforces perfect forwarding in the implementation of
folly::Future, thereby reducing the number of times that a callable
that is passed to Future::then et al. gets passed by value.
Before folly::Function, Future::then(callback) has invoked the move
constructor of the callback type 5 times for small callback objects
(fitting into the in-place storage inside folly::detail::Core) and
6 times for large callback objects. This has been reduced to 5 times
in all cases with the switch to UniqueFunction. This diff reduces it
to 2 times.
Reviewed By: yfeldblum
Differential Revision:
D2976647
fb-gh-sync-id:
9da470d7e9130bd7ad8af762fd238ef9a3ac5892
fbshipit-source-id:
9da470d7e9130bd7ad8af762fd238ef9a3ac5892