execute callbacks as rvalue references
authorSven Over <over@fb.com>
Mon, 6 Feb 2017 16:13:01 +0000 (08:13 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 6 Feb 2017 16:17:57 +0000 (08:17 -0800)
commit8898db4486a307b2d4034446f25b87e25d40eccd
treea6e530e16e951d883f95300bca54e6bd9cd6df1b
parentef2e3d4b5062d61a61aae45487a8bda5540295a9
execute callbacks as rvalue references

Summary:
Callable objects may implement a separate `operator()` for when
they are called as rvalue references. For example, `folly::partial`
will move captured objects to the function call when invoked as
rvalue reference. That allows e.g. to capture pass a `unique_ptr`
to `folly::partial` for a function that takes a `unique_ptr` by
value or rvalue-reference.

Callbacks for `folly::Future`s are only ever executed once. They
may consume captured data. If the callback is an object that
implements a `operator()() &&`, then that one should be invoked.

This diff makes sure, callbacks passed to `folly::Future` are
invoked as rvalue references.

Reviewed By: ericniebler, fugalh

Differential Revision: D4404186

fbshipit-source-id: 9f33e442a634acb8797183d3d869840d85bd5d15
folly/futures/Future-inl.h
folly/futures/test/FutureTest.cpp