folly/futures: replace MoveWrappers with generalised lambda capture
authorSven Over <over@fb.com>
Tue, 5 Apr 2016 18:34:21 +0000 (11:34 -0700)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Tue, 5 Apr 2016 18:35:36 +0000 (11:35 -0700)
commit76663af23df01607f74c00c449852f71e5d3f771
tree2f2cbe093da03e1084f4ff1cf812ab53adff95ad
parenta92b878a9c9928214b15f2f5b49c31032e9fb772
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
folly/experimental/fibers/FiberManager-inl.h
folly/futures/Future-inl.h
folly/futures/Future-pre.h
folly/futures/Future.h
folly/futures/detail/Core.h
folly/futures/helpers.h
folly/futures/test/EnsureTest.cpp