folly::fibers: do not move out of lvalue references
Summary:If you pass an lvalue to folly::fibers::Fiber::setFunction or
setFunctionFinally, you do not expect that those methods move
the function out of your lvalue.
This diff uses std::forward for perfect forwarding, so if an lvalue
is passed, a copy is made.
If and when when start using folly::Function for storing the
functions in the Fiber object, passing an lvalue will trigger a
compiler error because folly::Function is not copyable. That is
a good thing, as it enforces calling setFunction with std::move
if you use a named object, making clear that the named object
gets moved out of. Often people will pass temporary objects
(like a lambda defined i- place), which a rvalues anyway, so
this will not be a problem anyway.
Reviewed By: andriigrynenko
Differential Revision:
D3102685
fb-gh-sync-id:
87bf3135f7f6630766f97be351599ff488e4b796
fbshipit-source-id:
87bf3135f7f6630766f97be351599ff488e4b796