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

Deprecate executor-taking forms of Future::then

Summary:
Deprecate Future::then(executor, callback) pending removal.

This form of Future::then is ambiguous, and does not yet implement the stronger
typing of thenValue and thenTry. It is also tempting to use instead of via,
where it is not obvious that it has the behaviour of wrapping a via call in a
push and pop of the current executor:
.pushCurrentExecutor().via(executor).then(callback).popCurrentExecutor().

With the addition of inline continuations, we can instead make the nesting
explicit at low cost by making it an inline continuation that launches an
asynchronous task on the passed executor.

Reviewed By: yfeldblum

Differential Revision: D16282826

fbshipit-source-id: a94c994cf02f43f7a2bd857237885b25591fa9aa
parent 9cdbf0f1
......@@ -1185,7 +1185,13 @@ class Future : private futures::detail::FutureBase<T> {
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
template <class Arg>
auto then(Executor::KeepAlive<> x, Arg&& arg) && {
// clang-format off
[[deprecated("then forms that take an executor are ambiguous. "
"Replace with nested tasks, or for executor enforcement use "
"SemiFuture-returning functions.")]]
// clang-format on
auto
then(Executor::KeepAlive<> x, Arg&& arg) && {
auto oldX = getKeepAliveToken(this->getExecutor());
this->setExecutor(std::move(x));
// TODO(T29171940): thenImplementation here is ambiguous
......@@ -1203,7 +1209,13 @@ class Future : private futures::detail::FutureBase<T> {
}
template <typename R, typename... Args>
auto then(Executor::KeepAlive<>&& x, R (&func)(Args...)) && {
// clang-format off
[[deprecated("then forms that take an executor are ambiguous. "
"Replace with nested tasks, or for executor enforcement use "
"SemiFuture-returning functions.")]]
// clang-format on
auto
then(Executor::KeepAlive<>&& x, R (&func)(Args...)) && {
return std::move(*this).then(std::move(x), &func);
}
......
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