Commit 2139ed4c authored by Lee Howes's avatar Lee Howes Committed by Facebook Github Bot

Deprecate legacy forms of Future::then

Summary:
Deprecate the legacy forms of Future::then to assist migration to thenValue and thenTry.

This is part of a longer process to improve type correctness for folly::Future. By separating the forms of then we no longer have ambiguity when passing a polymorphic lambda as a continuation and can more easily tweak the implementation to modernise it.

Reviewed By: yfeldblum, WillerZ

Differential Revision: D9974379

fbshipit-source-id: 26f986329cb5d2d33d366b8f9e7b2664656642ff
parent 07f90764
......@@ -2332,7 +2332,10 @@ std::vector<Future<Result>> map(It first, It last, F func) {
std::vector<Future<Result>> results;
results.reserve(std::distance(first, last));
for (auto it = first; it != last; it++) {
FOLLY_PUSH_WARNING
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
results.push_back(std::move(*it).then(func));
FOLLY_POP_WARNING
}
return results;
}
......@@ -2342,7 +2345,10 @@ std::vector<Future<Result>> map(Executor& exec, It first, It last, F func) {
std::vector<Future<Result>> results;
results.reserve(std::distance(first, last));
for (auto it = first; it != last; it++) {
FOLLY_PUSH_WARNING
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
results.push_back(std::move(*it).via(&exec).then(func));
FOLLY_POP_WARNING
}
return results;
}
......
......@@ -1153,7 +1153,7 @@ class Future : private futures::detail::FutureBase<T> {
/// thenTry or thenError rather than then and onError as they avoid ambiguity
/// when using polymorphic lambdas.
template <typename F, typename R = futures::detail::callableResult<T, F>>
typename std::enable_if<
[[deprecated("use thenValue instead")]] typename std::enable_if<
!is_invocable<F>::value && is_invocable<F, T&&>::value,
typename R::Return>::type
then(F&& func) && {
......@@ -1161,7 +1161,7 @@ class Future : private futures::detail::FutureBase<T> {
}
template <typename F, typename R = futures::detail::callableResult<T, F>>
typename std::enable_if<
[[deprecated("use thenTry instead")]] typename std::enable_if<
!is_invocable<F, T&&>::value && !is_invocable<F>::value,
typename R::Return>::type
then(F&& func) && {
......@@ -1169,6 +1169,7 @@ class Future : private futures::detail::FutureBase<T> {
}
template <typename F, typename R = futures::detail::callableResult<T, F>>
[[deprecated("use thenValue(auto&&) or thenValue(folly::Unit) instead")]]
typename std::enable_if<is_invocable<F>::value, typename R::Return>::type
then(F&& func) && {
return this->template thenImplementation<F, R>(
......@@ -1241,9 +1242,12 @@ class Future : private futures::detail::FutureBase<T> {
auto then(Executor* x, Arg&& arg, Args&&... args) && {
auto oldX = this->getExecutor();
this->setExecutor(x);
FOLLY_PUSH_WARNING
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
return std::move(*this)
.then(std::forward<Arg>(arg), std::forward<Args>(args)...)
.via(oldX);
FOLLY_POP_WARNING
}
template <class Arg, class... Args>
......
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