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

Remove thenMulti

Summary: Another overload that is not really necessary and adds complication. Removing to simplify.

Reviewed By: yfeldblum

Differential Revision: D15110009

fbshipit-source-id: a7a90799ff4d89d45ae82d2e755be5ee3799104c
parent c5d71971
...@@ -1743,64 +1743,6 @@ class Future : private futures::detail::FutureBase<T> { ...@@ -1743,64 +1743,6 @@ class Future : private futures::detail::FutureBase<T> {
template <class I, class F> template <class I, class F>
Future<I> reduce(I&& initial, F&& func) &&; Future<I> reduce(I&& initial, F&& func) &&;
/// Create a Future chain from a sequence of continuations. i.e.
///
/// f.then(a).then(b).then(c)
///
/// where f is a Future<A> and the result of the chain is a Future<D>
/// becomes
///
/// std::move(f).thenMulti(a, b, c);
///
/// Preconditions:
///
/// - `valid() == true` (else throws FutureInvalid)
///
/// Postconditions:
///
/// - Calling code should act as if `valid() == false`,
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
template <class Callback, class... Callbacks>
auto thenMulti(Callback&& fn, Callbacks&&... fns) && {
// thenMulti with two callbacks is just then(a).thenMulti(b, ...)
// TODO(T29171940): Switch to thenImplementation here. It is ambiguous
// as then used to be but that is better than keeping then in the public
// API.
using R = futures::detail::callableResult<T, decltype(fn)>;
return std::move(*this)
.thenImplementation(std::forward<Callback>(fn), R{})
.thenMulti(std::forward<Callbacks>(fns)...);
}
/// Create a Future chain from a sequence of callbacks.
///
/// Preconditions:
///
/// - `valid() == true` (else throws FutureInvalid)
///
/// Postconditions:
///
/// - Calling code should act as if `valid() == false`,
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
template <class Callback>
auto thenMulti(Callback&& fn) && {
// thenMulti with one callback is just a then
// TODO(T29171940): Switch to thenImplementation here. It is ambiguous
// as then used to be but that is better than keeping then in the public
// API.
using R = futures::detail::callableResult<T, decltype(fn)>;
return std::move(*this).thenImplementation(std::forward<Callback>(fn), R{});
}
template <class Callback>
auto thenMulti(Callback&& fn) & {
return std::move(*this).thenMulti(std::forward<Callback>(fn));
}
/// Moves-out `*this`, creating/returning a corresponding SemiFuture. /// Moves-out `*this`, creating/returning a corresponding SemiFuture.
/// Result will behave like `*this` except result won't have an Executor. /// Result will behave like `*this` except result won't have an Executor.
/// ///
......
...@@ -171,29 +171,6 @@ TEST_F(ViaFixture, viaAssignment) { ...@@ -171,29 +171,6 @@ TEST_F(ViaFixture, viaAssignment) {
auto f2 = f.via(eastExecutor.get()); auto f2 = f.via(eastExecutor.get());
} }
TEST(Via, chain1) {
EXPECT_EQ(42, makeFuture().thenMulti([] { return 42; }).get());
}
TEST(Via, chain3) {
int count = 0;
auto f = makeFuture().thenMulti(
[&] {
count++;
return 3.14159;
},
[&](double) {
count++;
return std::string("hello");
},
[&] {
count++;
return makeFuture(42);
});
EXPECT_EQ(42, std::move(f).get());
EXPECT_EQ(3, count);
}
struct PriorityExecutor : public Executor { struct PriorityExecutor : public Executor {
void add(Func /* f */) override { void add(Func /* f */) override {
count1++; count1++;
......
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