Commit 8146802f authored by Lee Howes's avatar Lee Howes Committed by Facebook Github Bot

Remove l-value qualified folly::Future::then

Summary:
Overall plan to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.

The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.

Diff to remove the l-value qualified version of folly::Future::then.

Post on the topic of improving safety of Future: https://fb.facebook.com/groups/fbcode/permalink/1726007767436055/

Reviewed By: marshallcline

Differential Revision: D9175988

fbshipit-source-id: 942ae3e1548e8538497eaa0cbde68829c3145d1d
parent 97b5e617
......@@ -1155,9 +1155,7 @@ class Future : private futures::detail::FutureBase<T> {
template <typename F, typename R = futures::detail::callableResult<T, F>>
[[deprecated("must be rvalue-qualified, e.g., std::move(future).then(...)")]]
typename R::Return
then(F&& func) & {
return std::move(*this).then(std::forward<F>(func));
}
then(F&& func) & = delete;
/// Variant where func is an member function
///
......@@ -1186,11 +1184,9 @@ class Future : private futures::detail::FutureBase<T> {
template <typename R, typename Caller, typename... Args>
[[deprecated(
"must be rvalue-qualified, e.g., std::move(future).then(...)")]] Future<typename isFuture<R>::
Inner>
then(R (Caller::*func)(Args...), Caller* instance) & {
return std::move(*this).then(func, instance);
}
"must be rvalue-qualified, e.g., std::move(future).then(...)")]]
Future<typename isFuture<R>::Inner>
then(R (Caller::*func)(Args...), Caller* instance) & = delete;
/// Execute the callback via the given Executor. The executor doesn't stick.
///
......@@ -1226,9 +1222,7 @@ class Future : private futures::detail::FutureBase<T> {
template <class Executor, class Arg, class... Args>
[[deprecated(
"must be rvalue-qualified, e.g., std::move(future).then(...)")]] auto
then(Executor* x, Arg&& arg, Args&&... args) & {
return std::move(*this).then(x, arg, args...);
}
then(Executor* x, Arg&& arg, Args&&... args) & = delete;
/// When this Future has completed, execute func which is a function that
/// can be called with `Try<T>&&` (often a lambda with parameter type
......@@ -1378,9 +1372,7 @@ class Future : private futures::detail::FutureBase<T> {
Future<Unit> then() &&;
[[deprecated("must be rvalue-qualified, e.g., std::move(future).then()")]]
Future<Unit> then() & {
return std::move(*this).then();
}
Future<Unit> then() & = delete;
/// Convenience method for ignoring the value and creating a Future<Unit>.
/// Exceptions still propagate.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment